Microsoft.SqlServer.Types is slowing down a call to Form.ActiveForm by a factor of 100!
- From: Patrick van Dijk <patrick.van.dijk@xxxxxxxxx>
- Date: Mon, 8 Jun 2009 10:41:34 -0700 (PDT)
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());
}
}
.
- Follow-Ups:
- Prev by Date: Re: RegEx :
- Next by Date: Re: Microsoft.SqlServer.Types is slowing down a call to Form.ActiveForm by a factor of 100!
- Previous by thread: RegEx :
- Next by thread: Re: Microsoft.SqlServer.Types is slowing down a call to Form.ActiveForm by a factor of 100!
- Index(es):
Relevant Pages
|