rational.js vs fraction.js vs ratio.js - subtract, multiply, add, divide
JavaScript performance comparison
Preparation code
<script src="https://raw.github.com/acerix/rational.js/master/dist/rational.js">
</script>
<script src="https://raw.github.com/ekg/fraction.js/master/fraction.js"></script>
<script src="https://raw.github.com/LarryBattle/Ratio.js/master/lib/Ratio-0.3.11.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var test_cases = [
[3466463461, 134534331],
[12312337, 334534535],
[3453453, 3653450],
[53453453411, 365340],
[123453453, 3653453450],
[-173646341, 36345340],
[245345213, 2353523],
[212151121, 234234666],
[234235535, 234234666],
[-656755537, 65676767]
];
var float_1 = 1 / 10;
var float_2 = 111 / 3;
var rat_1 = rat.fromValues(1, 10);
var rat_2 = rat.fromValues(111, 3);
var ratio_1 = Ratio(1, 10);
var ratio_2 = Ratio(111, 3);
var frac_1 = new Fraction(1, 10);
var frac_2 = new Fraction(111, 3);
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
native float approximation |
|
pending… |
rational.js calculation |
|
pending… |
Ratio.js |
|
pending… |
fraction.js |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 9: published
0 comments