Hacker Newsnew | past | comments | ask | show | jobs | submit | deegu's commentslogin

CPU frequency scaling can also lead to somewhat unintuitive results. On few occasions I've seen CPU load % increasing significantly after code was optimized. Optimization was still actually valid, and the actual executed instructions per work item went down, but the CPU load % went up since OS decided to clock down the CPU due to reduced workload.


if you run it with luajit -jv primes.lua you'll see NYIs about math.mod not implemented.

Replacing math.mod(n, i) with (n % i) gives roughly 9.4x performance.

EDIT: luajit version was LuaJIT 2.0.4 on Mac OSX


Thanks, using % did the trick.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: