Source

Branch

1/ @stuartcarnie

@nicbarkeragain

It also matters how random the data is. If the branch predictor can identify patterns, the results will be much closer. For example setting the data to i % 3 results in <3x difference

2/ @nicbarkeragain

@stuartcarnie

Yes, the gap will close significantly if the branch predictor is able to do a good job with the data at hand!