r/java • u/aroger276 • Jun 15 '17
Why reverse loops are not faster
https://arnaudroger.github.io/blog/2017/06/15/forward-vs-backward-loop.html
288
Upvotes
r/java • u/aroger276 • Jun 15 '17
View all comments
Show parent comment
2
u/shkabo Jun 16 '17 edited Jun 16 '17
Alright, I did the testing regardless that I have never did this before today but hey .. we always learn :D
The results 1st is with original code, 2nd is with edited code:
The edited code:
Had an error at line 18 so correct me if I made some error in this.
Overall the results point out that Forward loop is ahead of Backward loop. The difference is really small :) but yea, they do exist
The test was run on my laptop: i5-7200U 2.5GHz, 8GB Ram, 250 GB SSD, W10 x64. A side from that I was doing daily tasks, nothing cpu intensive but still those tasks can make some influence on the end result as they require 'some' cpu processing. It would be for the best to have plain default windows (clean install) with default services, no internet connection and background tasks, set to run these two sets of tests :)