On 9 Jan, mirtchov@cpsc.ucalgary.ca wrote: > Rog at vitanuova already caught how stupid the following article is > (linked to from slashdot): > > http://osnews.com/story.php?news_id=5602 > > It took me much longer -- until I looked at their "C" code (term used > very loosely) trying to compile it on Plan 9... There are multiple > gems in it including ++ on a double, mid-function variable definitions > (C-code, right?), log10(0.0), impossible to look at I/O, etc. In > fact, I'm attaching the benchmark for your viewing pleasure :) > > Anyway, the exercise took very little time and here are some "results" > showing how good Plan 9's compiler are (where's a Bushnell when you > need one?), it would be interesting to see how the long arithmetic can be improved: > > pcc (code untouched except for mid-function variable definitions moved to top): > > Int arithmetic elapsed time: 17540 ms with intMax of 1000000000 > i: 1000000001 > intResult: 1 > Double arithmetic elapsed time: 65500 ms with doubleMin 10000000000.000000, doubleMax 11000000000.000000 > i: 11000000000.000000 > doubleResult: 10011632717.495501 > Long arithmetic elapsed time: 262540 ms with longMin I64d, longMax I64d > i: I64d > longResult: I64d > Trig elapsed time: 25070 ms with max of 10000000 > i: 10000000.000000 > sine: 0.990665 > cosine: -0.136322 > tangent: -7.267119 > logarithm: 7.000000 > squareRoot: 3162.277502 > [crashes during the last test while reading back the file it just wrote] > > gcc (code untouched, no -O): > > Int arithmetic elapsed time: 23770 ms with intMax of 1000000000 > i: 1000000001 > intResult: 1 > Double arithmetic elapsed time: 56040 ms with doubleMin 10000000000.000000, doubleMax 11000000000.000000 > i: 11000000000.000000 > doubleResult: 10011632717.495501 > Long arithmetic elapsed time: 53500 ms with longMin I64d, longMax I64d > i: I64d > longResult: I64d > Trig elapsed time: 30680 ms with max of 10000000 > i: 10000000.000000 > sine: 0.990665 > cosine: -0.136322 > tangent: -7.267119 > logarithm: 7.000000 > squareRoot: 3162.277502 > [crashes during the last test while reading back the file it just wrote] > > 8c (modified to use nsec() for timing, printf -> print, fixed log10(0.0) crash, fix %I64d in print()): > > Int arithmetic elapsed time: 17517 ms with intMax of 1000000000 > i: 1000000001 > intResult: 1 > Double arithmetic elapsed time: 22525 ms with doubleMin 10000000000.000000, doubleMax 11000000000.000000 > i: 11000000000.000000 > doubleResult: 10011632717.495500 > Long arithmetic elapsed time: 565067 ms with longMin 10000000000, longMax 11000000000 > i: 11000000000 > longResult: 776627965 > Trig elapsed time: 25881 ms with max of 10000000 > i: 10000000.100000 > sine: 0.972106 > cosine: -0.234542 > tangent: -4.144701 > logarithm: 7.000000 > squareRoot: 3162.277518 > > > It is important to note that the integer performance of 8c is > comparable to gcc 3.3's -O[23] running on Plan 9 and Linux > respectively. The double arithmetic lags by about 20%. The I/O is > comparable (2x slower when going over a 100mbit link, no caching). > > Profiling the long long code to see where it looses all that time may > be interesting. > > All computation performed on a 8-way 700mhz Xeon, only 1 cpu used :) > > Sorry for wasting your time -- just wanted to see how good 8c was and > got caught in all the other crap. It's Friday after all... :) > > Andrey That's what I get on SGI Octane R12k/270MHz with the MIPSpro 7.3 C++ compiler as my MIPSpr C compiler is too much standard... Start C benchmark Int arithmetic elapsed time: 32870 ms with intMax of 1000000000 i: 1000000001 intResult: 1 Double arithmetic elapsed time: 21700 ms with doubleMin 10000000000.000000, doubleMax 11000000000.000000 i: 11000000000.000000 doubleResult: 10011632717.495501 Long arithmetic elapsed time: 72920 ms with longMin I64d, longMax I64d i: I64d longResult: I64d Trig elapsed time: 5730 ms with max of 10000000 i: 10000000.000000 sine: 0.990665 cosine: -0.136322 tangent: -7.267119 logarithm: 7.000000 squareRoot: 3162.277502 I/O elapsed time: 3540 ms with max of 1000000 last line: abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefgh Total elapsed time: 136760 ms Stop C benchmark -- BEATVSHOMOQVIINVENITSAPIENTIAMETQVIAFFLVITPRVDENTIALIVRILVCIFERIVS