Microsoft.SqlServer.Types is slowing down a call to Form.ActiveForm by a factor of 100!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I am running into a situation where when I load
Microsoft.SqlServer.Types my app is running slower.
To show you what is going on, I've been able to get the smallest app
as possible.
This will do 5000 times Form.ActiveForm and measure it's time.
It should be much and at first it is less than 0.002 seconds.
Even the version which is doing a recursive call of itself till 200
deep, says 0.002.
However, after I've done:

Microsoft.SqlServer.Types.SqlGeography geography = null;

which just loads Microsoft.SqlServer.Types.dll, the numbers get a lot
higher.
The method which directly calls Form.ActiveForm about 5000 times says
0.017 sec, but the one
which does it after 200 recursions then performs it in 0.250 sec,
which is more than 100 times slower !


When one runs the app and invokes Test1() and TestDeep() via buttons,
the numbers get even worse.

Please help,

Pat


public class Form1 : Form
{
public Form1()
{
}

public void Test1()
{
int max = 5000;

System.Diagnostics.Stopwatch sw =
System.Diagnostics.Stopwatch.StartNew();
for (int i = 0; i < max; i++)
{
Form form = Form.ActiveForm;
}

sw.Stop();
double time = sw.ElapsedMilliseconds / 1000.0;
MessageBox.Show(String.Format("Time: {0}, Average: {1}", time,
time / max));
}

public void TestDeep(int level)
{
if (level > 0)
{
TestDeep(--level);
}
else
{
Test1();
}
}

public void Test3()
{
Microsoft.SqlServer.Types.SqlGeography geography = null;
MessageBox.Show("Sql Server Types Loaded");
}
}



static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

Form1 form = new Form1();
form.Show();

form.Test1();
form.TestDeep(200);
form.Test3();

form.Test1();
form.TestDeep(200);

//Application.Run(new Form1());
}
}

.



Relevant Pages

  • Re: Mobile Development for WM 5 with one main exe controlling mult
    ... I'm trying to convince them with what you said about the load strategy, ... it could be due to the fact that all the loading are done ... App size has nothing ... split the whole program from one exe to multiple. ...
    (microsoft.public.pocketpc.developer)
  • Re: Reprise: Pended IOCtrl + LoadLibrary == Deadlock?
    ... >3) launching msdev.exe from the shell and from within windbg. ... >load (from within msdev) ionwizrd.exe ... When I hit F5 to run my app the following occurs: ...
    (microsoft.public.development.device.drivers)
  • Re: Whose Fish?
    ... That would be much more in line with your Table Oriented Programming ... cart structure/object floating around in the app. ... intuitive way, as it is with a good object model, ... I might load CustomerInfo with read only ID ...
    (comp.object)
  • Re: Reprise: Pended IOCtrl + LoadLibrary == Deadlock?
    ... > and execute!htrace in both devenv.exe and the target app. ... launching msdev.exe from the shell and from within windbg. ... All other cases either result in not being able to run msdev or my app ... itself both when it starts up and when it is trying to load my app. ...
    (microsoft.public.development.device.drivers)
  • Re: Dynamically-created menus and mdi children
    ... I created the new app and it worked. ... my main form is not the first form that opens. ... I open the Main Form and close the Login form. ... Otherwise my main form continues to load and I load ...
    (microsoft.public.dotnet.languages.vb)