Ratio.js
Ratio.js copied to clipboard
Redo benchmark
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
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