Re: Tiny typo in Manual
- Posted by Jeremy Cowgar Jul 14, 2008
- 878 views
Jeremy Cowgar said...
Shawn Pringle said...
There was also something about platform() being slower than using ifdef which we know isn't true.
Um, it is true. Here are two sample programs anyone can run:
test1.ex
include os.e integer c = 0 for a = 1 to 100000 do if platform() = LINUX then c = a * 2 end if end for ? c
test2.ex
integer c = 0 for a = 1 to 100000 do ifdef LINUX then c = a * 2 end ifdef end for ? c
Here are my results, but please run them and see if you find similar results. It's rather large.
jeremy@cowgar:~$ time exu test1.ex 200000 real 0m0.130s user 0m0.028s sys 0m0.004s jeremy@cowgar:~$ time exu test2.ex 200000 real 0m0.004s user 0m0.004s sys 0m0.000s
You should set the platform and ifdef call to your own platform.
I updated those two programs, I made the iteration be 100,000,000 and I included os.e in test2.e for parsing fairness (i.e. the first one had to parse it, so make the second parse it even though it's not directly needed by ifdef). Here are those results:
jeremy@cowgar:~$ time exu test1.e 200000000 real 0m1.016s user 0m0.924s sys 0m0.004s jeremy@cowgar:~$ time exu test2.e 200000000 real 0m0.693s user 0m0.688s sys 0m0.004s
Jeremy