|Table vs switch parser benchmark Tom@elysium.demon.co.uk (Tom) (2003-09-23)|
|Date:||23 Sep 2003 12:56:04 -0400|
|Posted-Date:||23 Sep 2003 12:56:04 EDT|
I thought some people here might be interested in a little program I have
spent the last 45 minutes writing that benchmarks two very simple
backtracking NFAs against each other, as the subject suggests one
implemented with a switch statement the other with tables. The parsers count
line breaks - CRLF, LFCR and LFs and CRs on their own.
These are the resutls on my athlon XP on windows (xp):
 F:\--->>gcc smtest.c -O3 -o smtest.exe && smtest
No data.txt, using internal data.
Begin testing 57K of data 18199 times (1023MB total)...
Switch parser reported 4000 breaks and executed in 12.257000 seconds.
Table parser reported 4000 breaks and executed in 13.197000 seconds.
Without optimization the table parser fared much worse:
Switch parser reported 4000 breaks and executed in 27.333000 seconds.
Table parser reported 4000 breaks and executed in 45.807000 seconds.
I have posted the standard C source and a windows binary here:
Return to the
Search the comp.compilers archives again.