bench(loop,factorial,10000000,45)=567ms
10000000 loops in 567ms.
Can your Haskell do this?
function factorial(x){for(var i=x-1;i>0;i--){x*=i};return x}
function bench(x,y,z,z1,z2,z3,z4,z5,z6,z7,z8,z9,z10){var d=new Date();var std=d.getTime();var res=x(y,z,z1,z2,z3,z4,z5,z6,z7,z8,z9,z10);var d2=new Date();var std2=d2.getTime();
var diff=std2-std;return diff}
function loop(x,y,z,z1,z2,z3,z4,z5,z6,z7,z8,z9,z10){for(var i=y-1;i>-1;i--){var res=x(z,z1,z2,z3,z4,z5,z6,z7,z8,z9,z10)}}
>>26
Its archives posts from 3 years ago.
It has more programming topics then /g/(/g/ Quality is down recently).
Its threads do not expire and easier to track.
I don't understand >>34
Its summing integers inline? or there some subtle context?
Name:
FrozenVoid!FrOzEn2BUo2009-01-05 13:45
>>34
Its seems to calculate sum of excel cells. waste of variables.
bench() doesn't use arguments array because the code would
include a slower for(;;) and conditional which would made the benchmarks slower.
It needs to pass these 10 arguments millions of times.
Speed in benchmarking is critical.
Without z1-z10 ,parsing arguments array 10 millions times would be way slower then my optimized functions, completely ruining the purpose of bench().
>>37
The stack is an "array" too, it requires memory access unless you pass arguments as registers, that said, passing 10 arguments directly will use the stack on a x86, as you can only pass 2-3 arguments as registers, so you implementation would be either slower or have similar speed to one using an args array. If you really cared about speed of your benchmarking function, you would have coded it in asm, and used the CPU instruction which returns ticks, if such a thing exists on your platform( rdtsc instruction for x86), and probably would have inlined the entire benchmark function too.
Name:
FrozenVoid!FrOzEn2BUo2009-01-05 14:04
I'm interested in programming in assembler.
However there certain features (like size of code),memory management and some opcodes i can't understand.
>>38
You'll have to be more specific with your questions, I don't understand what you mean by ``size of code".
As for memory management, if you're writting an OS, or something similar ( like a debugger which doesn't depend on the OS ), you'll have to do the memory management yourself by modifying the needed descriptors and tables, details for this can be found in the fine manuals, otherwise, you should just call whatever APIs or library functions are provided to you by the OS to do the allocation of freeing of memory. Can't answer the third question since you gave no details, but I'm sure reading the fine manuals will give you the answer.
Name:
FrozenVoid!FrOzEn2BUo2009-01-05 14:27
>>39
[size of code]
how much text would factorial+bench+loop take in asm?
I assume about 5 times. They could be more optimized but you have to maintain alot more code.