Ratio.js icon indicating copy to clipboard operation
Ratio.js copied to clipboard

Redo benchmark

Open LarryBattle opened this issue 11 years ago • 1 comments

Add a benchmark script to the build script, so that we can get stats just by running npm run benchmark. Please include tests from other libraries. Here's a start. http://jsperf.com/convert-a-rational-number-to-a-babylonian-fractions/22

Related issue: https://github.com/LarryBattle/Ratio.js/issues/50

LarryBattle avatar Oct 07 '14 02:10 LarryBattle

The problem with this benchmark is that .simplify() is being called after each operation. Not sure why the original author did that.

Source:

for (var i in test_cases) {
  ratio_1 = Ratio(test_cases[i][0], test_cases[i][1]);
  ratio_2 = ratio_2.subtract(ratio_1).simplify().multiply(ratio_1).simplify().add(ratio_1).simplify().divide(ratio_1).simplify();
}

Goals: Make this work.

for (var i in test_cases) {
  ratio_1 = Ratio(test_cases[i][0], test_cases[i][1]);
  ratio_2 = ratio_2.subtract(ratio_1).multiply(ratio_1).add(ratio_1).divide(ratio_1);
}

Related ticket: https://github.com/LarryBattle/Ratio.js/issues/57

LarryBattle avatar Nov 05 '14 18:11 LarryBattle