Re: [Haskell] ANNOUNCE: jhc 0.6.0 Haskell Compiler
nice, although not quite fair, as jhc always has optimization turned on, so compiling the others with -O is more appropriate. The 'show' instance is clearly eating up most of the time in the jhc version, if you look at the generated C code. here is main as generated by jhc annotated with the haskell it cooresponds to in the comments : static void A_STD ftheMain(void) { // passing in 100000000 to countdown uint32_t v184744394 = 10000000; // countdown :: Int -> IO () fW_a__fMain__fl_aMain__countdown_d43_u8:; { sptr_t v261990436 = ((sptr_t)VALUE(v184744394)); // check if it is zero if (0 == v184744394) { // putStr "finished" fPrelude__IO__putStr(c8); // putChar '\n' return (void)jhc_utf8_putchar((int)10); } else { // let s = show x wptr_t v100000 = fInstance_a__iJhc__Show__show__default(v261990436); sptr_t v118875000 = demote(v100000); // putsStr s fPrelude__IO__putStr(v118875000); // putChar '\n' (void)jhc_utf8_putchar((int)10); // jump to countdown with x = x - 1 uint32_t v14532078 = (v184744394 - 1); v184744394 = v14532078; goto fW_a__fMain__fl_aMain__countdown_d43_u8; } } } John -- John Meacham - ⑆repetae.net⑆john⑈
so compiling the others with -O is more appropriate.
It seems the consensus is I should have activated optimizations. Let check that, same code in the same order (ghc, jhc, gcc). I changed only the options for ghc and gcc. Below is the Makefile, you can double check. with -O 0:09.96 real,9.86 user,0.06 sys 0:02.06 real,1.02 user,0.92 sys 0:02.80 real,2.55 user,0.00 sys with -O2 0:09.81 real,9.70 user,0.07 sys 0:01.95 real,1.01 user,0.93 sys 0:02.57 real,2.56 user,0.00 sys with -O3 0:09.86 real,9.78 user,0.06 sys 0:01.98 real,1.02 user,0.95 sys 0:02.63 real,2.64 user,0.00 sys I have tried with gcc 3.4 and 4.3.2. All results are consistent. Sylvain Nahas Makefile --------------------- OPT:=-O3 CC:=gcc-3.4 CFLAGS:=-Wall $(OPT) JHC:=/home/sylvain/bin/jhc-0.6.0/bin/jhc GHCFLAGS:=$(OPT) TIMEFMT:=-f "%E real,%U user,%S sys" all: test1 test2 test3 .PHONY: test1 test2 test3 test1: hello1 time $(TIMEFMT) ./$^ >/dev/null test2: hello2 time $(TIMEFMT) ./$^ >/dev/null test3: hello3 time $(TIMEFMT) ./$^ >/dev/null hello1: hello.hs ghc $(GHCFLAGS) $^ -o $@ hello2: hello.hs $(JHC) $^ -o $@ hello3: hello.c $(CC) $(CFLAGS) $^ -o $@ clean: -rm hello1 hello2 hello3 hello.hi hello.ho hello_code
participants (2)
-
John Meacham -
sylvain