Table vs switch parser benchmark

"Tom" <Tom@elysium.demon.co.uk>
23 Sep 2003 12:56:04 -0400

          From comp.compilers

Related articles
Table vs switch parser benchmark Tom@elysium.demon.co.uk (Tom) (2003-09-23)
| List of all articles for this month |

From: "Tom" <Tom@elysium.demon.co.uk>
Newsgroups: comp.compilers
Date: 23 Sep 2003 12:56:04 -0400
Organization: Compilers Central
Keywords: optimize, performance
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:


http://p6.8k.com/


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.