|
|
|
|
|
by jostylr
3125 days ago
|
|
I added the floor loop to the code and made a console based webpage for it: http://jostylr.com/cleverdumb.html Kind of hackish, but you can open it up in a browser and look at the console for the run times. Basically, the clever code is generally worse, and the arrow versus for loop in Firefox and Safari are similar. But in Chrome, the for loop is quicker; it was far more noticeable in node than in chrome. One quirk of chrome is that the first time the for loop is run, it seems to take longer than subsequent runs and I am not sure why that is. I tried moving around initialization stuff and it did not seem to make any differences. Times from node: Prototype: 105.467ms
Arrow function: 106.674ms
For: 98.820ms
Prototype: 105.743ms
Arrow function: 106.192ms
For: 82.733ms
Prototype: 105.512ms
Arrow function: 106.517ms
For: 82.625ms
Basically, code in the comfortable style. I used to love for loops, but have now switched over to map and forEach when it makes sense to do so. |
|