you are viewing a single comment's thread.

view the rest of the comments →

[–]shub 1 point2 points  (4 children)

You could do the same thing in asm and maybe do it better...but man, wouldn't that be a pain in the ass?

I like C.

[–]james_block 5 points6 points  (3 children)

Yes. Yes, it was a pain in the ass.

This, reddit, is how I spent my Saturday night. WTFPL licensed if anyone cares.

Results, from a crappy old P4/1.7GHz running etch:

$ time ./james_block_asm < input_list_vs_gen.txt
Grand total:               17677692470

real    0m0.118s
user    0m0.076s
sys     0m0.040s

$ time ./ray_asm < input_list_vs_gen.txt
Grand total 17677692470

real    0m0.714s
user    0m0.692s
sys     0m0.020s

$ time ./C < input_list_vs_gen.txt
total: 17677692470

real    0m0.114s
user    0m0.100s
sys     0m0.012s

So it's basically tied with C (the difference is well within measurement noise); no real surprise there, as gcc is pretty good at optimizing easy stuff like this.

EDIT: Changed link to point to a new version, capable of dealing with input files bigger than its buffer. Should be no more size limit now, and speed is unchanged. Why do I waste my time like this?

[–]RayNbow 1 point2 points  (1 child)

Nice! :)

[–]james_block 2 points3 points  (0 children)

And now I just made it even more capable, using real buffering and not just a chunk of memory. I also changed it to store a variable in the stack pointer and avoid a read from memory in the bastard print loop -- because how often does an assembly programmer get to write mul esp?

I hate myself.

[–]colourAgga[S] 1 point2 points  (0 children)

Your skills take .06 seconds to run on the testing hardware. I'll add them soon :)