Hi C9 fellows,
today I was very very surprised and I'm still excited. .NET can be really fast, if you get it right. Today I wrote a Tokenizer for a parser I'm going to write.
The tokenizer has quite a few rules he is following. The class is like 350 lines of pure code.
I created a short demo application to test it.
for (int i = 0; i < 30; i++)
{
Tokenizer tokenizer =
new Tokenizer("(Upper(SubString(UserName, 1, 3)) = {0} And " +
"Call[Duration > \"]blah\"]) Or UserName = 'Christian' SortBy UserName Asc");
DateTime now =
DateTime.Now;
foreach (Token token
in tokenizer)
{
tokens.Add(token);
}
DateTime then =
DateTime.Now;
Console.WriteLine("Time #" + i + " in Milliseconds: " + ((TimeSpan)(then - now)).TotalMilliseconds + " ms");
}
As you see the string that is analyzed is quite complicated (see the constructor call).
Look at the output on the console:
Time #0 in Milliseconds: 10,0144 ms
Time #1 in Milliseconds: 0 ms
Time #2 in Milliseconds: 0 ms
Time #3 in Milliseconds: 0 ms
Time #4 in Milliseconds: 0 ms
Time #5 in Milliseconds: 0 ms
Time #6 in Milliseconds: 0 ms
Time #7 in Milliseconds: 0 ms
Time #8 in Milliseconds: 0 ms
Time #9 in Milliseconds: 0 ms
Time #10 in Milliseconds: 0 ms
Time #11 in Milliseconds: 0 ms
Time #12 in Milliseconds: 0 ms
Time #13 in Milliseconds: 0 ms
Time #14 in Milliseconds: 0 ms
Time #15 in Milliseconds: 0 ms
Time #16 in Milliseconds: 0 ms
Time #17 in Milliseconds: 0 ms
Time #18 in Milliseconds: 0 ms
Time #19 in Milliseconds: 0 ms
Time #20 in Milliseconds: 0 ms
Time #21 in Milliseconds: 0 ms
Time #22 in Milliseconds: 0 ms
Time #23 in Milliseconds: 0 ms
Time #24 in Milliseconds: 0 ms
Time #25 in Milliseconds: 0 ms
Time #26 in Milliseconds: 0 ms
Time #27 in Milliseconds: 0 ms
Time #28 in Milliseconds: 0 ms
Time #29 in Milliseconds: 0 ms
As you see the first run takes 10 milliseconds. After that (I do no caching) the "tokenizing" takes 0 milliseconds. It still takes some processor time, but I guess 10 milliseconds is the lowest unit you can measure with my technique.
I'm still surprised. Tumbs up for .NET!!!
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.