"Debug" vs "Release"??? Basically like you said before, EssGeEich and Zereo, "
When you're debugging, debug. When you're releasing, release. ". I totally agree.
Many thanks
Zereo. You encourage me a lot. :)
Actually In past I was disappointed about the parser speed. It's so slow. So I decided to insert some
assembly code, of course in some cases it's very effective. However, "assembly limit" is
it cannot access variable inside structures. Some complex expressions I reduced dozens of assembly commands but the parser still runs correctly. Here's one of assembly limit :
1 2 3 4 5
|
__asm mov eax var[0].value //Error
__asm mov eax dword ptr [var[0].value] //Error
int value = var[0].value; //Copy value
__asm mov eax value //Ok
| |
In my opinion, probably it's not fast, so I don't use it.
Final result : I think it doesn't make any noticeable result.
Next parser optimization is improving some
for-while loops. I reversed some
for loops and then set up my zero comparison in order to speed up the parsing. But it seems it's a ridiculous idea again, because I can't apply this tweak for primary loop...
I drunk some coffee, and then, implemented the
copy constructor idea. Certainly it's a good specific solution especially for
for-while script loop. You only need to analyze the expression once. Then the parser will automatically do all for you... :)
Finally I discovered a very magic...magical thing!!! By chance I switched my
Debug project mode to
Release. Then tested again I didn't believe that it was counting so fast! And I have no idea why the speed between
Debug and
Release is so different.
"Release" I see it's light, fast, only it can't be debugged. And
"Debug" programs are only added some debug symbols but they run very slowly (even I run them indirectly). And here is my latest result :
Compare this :
http://www.cplusplus.com/forum/lounge/85713/8/#msg473844
My statistics : (
10.000.000 loops)
x = 1+1+1+1+1+1+1+1+1+1
Result : 10
Time : 26.562 sec(s)
Length : 190.000.000
Speed : 376.478 (loops)
Characters per second : 7.153.075 (characters) |
y = 1+(((((((((((((((((((((((((((1 * 10)))))))))))))))))))))))))))
Result : 11
Time : 109.735 sec(s)
Length : 620.000.000
Speed : 91.128 (loops)
Characters per second : 5.639.974 (characters) |
With complex structure access...
z = num[num[0] + num[1] + num[2] + num[3] + num[4] + num[5]]
Result : 15
Time : 81.313 sec(s)
Length : 610.000.000
Speed : 122.982 (loops)
Characters per second : 7.501.875 (characters) |
num[num[num[num[num[num[num[num[num[num[10]+1]+1]+1]+1]+1]+1]+1]+1]+1]*2
Result : 38
Time : 126.406 sec(s)
Length : 720.000.000
Speed : 79.110 (loops)
Characters per second : 5.695.932 (characters) |
((num+=1) < 10000000) // num = 0
Result : 0 (Last loop)
Time : 24.671 sec(s)
Length : 210.000.000
Speed : 405.334 (loops)
Characters per second : 8.512.018 (characters) |