The benchmark was written for real life task: computing excel formulas. I understand that in real life there will be not only integers and that the benchmark is syntethic. But in any case the results are representetive enough.
We do calculation of abstract syntax tree that represents simple mathematical formula:
[SUM,
[SUBSTRACT,[ADD,[DIVIDE,[MULTIPLY,10,20],30],40],50],
[SUBSTRACT,[ADD,[DIVIDE,[MULTIPLY,20,30],40],50],60],
[SUBSTRACT,[ADD,[DIVIDE,[MULTIPLY,30,40],50],60],70],
[SUBSTRACT,[ADD,[DIVIDE,[MULTIPLY,40,50],60],70],80]
]
We do 100000 iterations and after comleting check the sum of all results to ensure that the calculations were not skipped by optimizer.
SUM should be implemented using loop. Do not use built-in "sum". Using external "sum" will be unfair for the following reasons:
Here is the result for Macbook Pro 2013: