B
Bill Butler
raylopez99 said:I'm curious how you did such a quick test, especially since the
DateTime structure is only accurate to at best 10 ms or greater.
You simply repeat each test about 100,000 times in a loop.
Viola!
raylopez99 said:I'm curious how you did such a quick test, especially since the
DateTime structure is only accurate to at best 10 ms or greater.
Bill said:You simply repeat each test about 100,000 times in a loop.
Viola!
techniques reach near-parity at just 5 concatenations, and StringBuilder
is definitively faster at 10 concatenations. At 20, there's no contest.
But Peter said:
Which implies he only tested five concatenations, and up to 20, no
more.
Jon said:You can repeatedly do 20 concatenations though. Doing 20
concatenations 100,000 times is not the same thing as doing 20 *
100,000 concatenations.
OK, I see. Do 20 loops, store the time difference, and repeat 100k
times. Makes sense.
DateTime structure is only accurate to at best 10 ms or greater.
raylopez99 said:I've been looking for a decent stopwatch, and have checked out various
MSDN articles that say it really can't be done (the one that says "if
you're looking for a metronome, you've come to the wrong place").
If you have code or pseudo code on this "Stopwatch" method, please
post here so I can add it to my bag of tricks aka library.
On a decent motherboard you should be able to get near microsecond
accuracy with that, which means you probably want to use
sw.Elapsed.TotalMilliseconds instead of sw.Milliseconds.
I've also
seen a few weird glitches with the latter where occasionally the
machine will hiccup and you'll be off by six orders of magnitude.
On a decent motherboard you should be able to get near microsecond
accuracy with that, which means you probably want to use
sw.Elapsed.TotalMilliseconds instead of sw.Milliseconds. I've also
seen a few weird glitches with the latter where occasionally the
machine will hiccup and you'll be off by six orders of magnitude.
Thanks !commie. On a related note, I've seen strange stuff with
garbage collected timers, they tend to "bunch up" and/or 'hiccup'
where they don't fire on time. The DateTime structure also has
a .Ticks "total milliseconds" (actually I think it's close to
nanoseconds, or some multiple of ns) from the year 0 AD that's also
good but the granularity of DateTime is >= 10ms, so that defeats the
purpose.
Thanks !commie. On a related note, I've seen strange stuff with
garbage collected timers, they tend to "bunch up" and/or 'hiccup'
where they don't fire on time. The DateTime structure also has
a .Ticks "total milliseconds" (actually I think it's close to
nanoseconds, or some multiple of ns) from the year 0 AD that's also
good but the granularity of DateTime is >= 10ms, so that defeats the
purpose.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.