Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Very good point. I was just surprised how much that simple bool assignment slowed things down so massively.


I started at 10.853, and with very little effort brought it down to 0.003

The slowdown isn't in assigning the bool; If you pass in 10000000 into that function, it's going to get isPrime set to true on the first iteration, but if you early out, you save all of those values. Again, this isn't really the point of the exercise, it's supposed to be comparing the performance of the same piece of code ran on different hardware.

https://gist.github.com/anonymous/c6d5bae04334cbc7ef9583ebb7...




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: