Re: c# static constructor?



I am not misunderstanding the article, and the code example given is too
simple for me to reproduce with any difference.
In the very classical example (very tight loop), they say the static
construtor code should be eight times slower, but I see no siginificant
difference at all.
Jon Skeet said, ".net 2.0 optimized it a bit". But, by comparing the result
given by the article, and my result, it's understatement by saying 'a bit."


"Oliver Sturm [MVP C#]" <oliver@xxxxxxxxxxxx> wrote in message
news:diukdt5p8ih4.dlg@xxxxxxxxxxxxxxx
Hi,

ms news group wrote:

I read one article that says static constructor can be a big performance
hit, it even gives some code fragment, which, accoring to that article,
could show a big difference betweeen using static constructor or not.
But
when I run his code, I found no significant diifference at all.

Then you're either misunderstanding the article or the environment in
which
you are running your test is not the same that the author of the article
was using.

Could someone shed some light on this?

Shed some light on what? Static constructors make an important bit of
functionality available to C# programmers. If you need that functionality,
use them. If not, don't. I've used countless static constructors myself
and
I wouldn't stop doing so unless I encounter a scenario where it is clear
that they are not working for me. And even then I'd suspect that the
behaviour in question would rather be a bug than a design feature.


Oliver Sturm
--
http://www.sturmnet.org/blog - MVP C#


.



Relevant Pages

  • Re: Slow startup on Windows service depending on system date (!??)
    ... reproduce it without fail: ... Did you also remove all code from static constructors, constructors, inline ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: c# static constructor?
    ... hit, it even gives some code fragment, which, accoring to that article, ... If you need that functionality, ... I've used countless static constructors myself and ...
    (microsoft.public.dotnet.framework.performance)

Loading