>>3
actually it makes no difference if you fold left or right in this case.
Name:
Anonymous2007-03-31 16:35 ID:TMGtAGig
Okay, I actually tested those this time, and for me, fac is about 1/3 slower and allocates 10% or so more memory than either fac' or fac'' on GHC 6.6 without any flags.
dammit, why did i copy pasta from 6, it should have been
xor ax,ax
lul:
inc ax
cmp ax,10000d
jl lol
[ax] would try to read memory from 0 to 10000 , thus causing access violations each and every time(not that there woudnt be a legitimate use to do so, and i have seen situations where it was actually needed), but not in this case..
Name:
Anonymous2007-04-01 0:25 ID:Ozs+yM4s
now for a factorial in asm:
mov ecx,n ; n is the variable n!
cdq ; clear edx, sign
xor eax,eax
inc eax
lbl:
imul ecx
dec ecx
jnz lbl
; eax now contains factorial, wasnt it fast :D
>>1
Not on my system. Anyway, almost all the time is spent doing the actual multiplication -- the overhead of callCC vs foldr is negligible. Change the (*) to (+), and you might actually be able to see the difference in overhead.
The current program spends almost all of its time in libgmp...
Name:
Anonymous2007-04-01 2:36 ID:qpfSC7D5
>>12
According to the Intel 8086 Opcode reference, an add reg16, mem is 3 cycles, whilst an inc reg16 is 2.
Name:
Anonymous2007-04-01 2:37 ID:qBiogR71
STOP TALKING ABOUT ASM IN MY CALLCC THREAD
Name:
Anonymous2007-04-01 2:41 ID:qpfSC7D5
>>14 here
How embarassing, seems like I misread. An add reg, imm is 2 cycles, just like an inc. However, it is shorter to type inc, so you save a few bytes on disk.