Switch implementation

Iain Buclaw ibuclaw at ubuntu.com
Tue Sep 28 18:38:24 PDT 2010


== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> Iain Buclaw:
> > Oh, it was my *original* intention to test runtime speed. However, the time to
> > compile just stood out little more like a sore thumb than what I anticipated.
> If your purpose is to test runtime speed, use a more natural number of cases
like 10 or 20 or even 50 :-)
> So I have done a better test, see below for the code.
> Timings, NLOOPS = 100_000, best of 6, seconds:
>   DMD: 7.70
>   GCC: 2.42
> gcc  4.5.1, -Wall -O3 -s
> dmd 2.049, -O -release -inline
--snip--
> Bye,
> bearophile

Well, this should give you a good comparison between case jump tables on and off
in GCC.

gdc-4.4 -O0
real	0m9.994s
user	0m9.957s
sys	0m0.028s

gdc-4.4 -O0 -fno-jump-tables
real	0m10.222s
user	0m10.197s
sys	0m0.012s

gdc-4.4 -O0 -funroll-loops
real	0m10.004s
user	0m9.965s
sys	0m0.032s

gdc-4.4 -O0 -funroll-loops -fno-jump-tables
real	0m10.011s
user	0m9.981s
sys	0m0.020s

gdc-4.4 -O3
real	0m7.107s
user	0m7.092s
sys	0m0.008s

gdc-4.4 -O3 -fno-jump-tables
real	0m7.136s
user	0m7.112s
sys	0m0.008s

gdc-4.4 -O3 -funroll-loops
real	0m7.127s
user	0m7.104s
sys	0m0.008s

gdc-4.4 -O3 -funroll-loops -fno-jump-tables
real	0m7.237s
user	0m7.184s
sys	0m0.044s

Differences are pretty minimal...


In comparison to DMD:

dmd -O
real	0m15.049s
user	0m14.989s
sys	0m0.044s


Iain


More information about the Digitalmars-d mailing list