Convert a rational number to a Babylonian fractions

JavaScript performance comparison

Revision 3 of this test case created

Info

Comparisons of algorithms to convert a rational number (a/b) to a sum of Babylonian fractions (rational numbers with a numerator of one)

Preparation code

<script src="//raw.github.com/acerix/jsscience/master/src/mathematics/number/Rational.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var test_cases = [
      [1, 10],
      [3, 360],
      [5, 360],
      [7, 360],
      [11, 360],
      [13, 360],
      [21, 666],
      [23, 666],
      [25, 666]
    ];
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
JSScience Rational->toBabylonian()
for (var i in test_cases) {
  new Rational(test_cases[i][0], test_cases[i][1]).toBabylonian();
}
pending…
JSScience Rational->toEgyptian()
for (var i in test_cases) {
  new Rational(test_cases[i][0], test_cases[i][1]).toEgyptian();
}
pending…
JSScience Rational->toDecimal()
for (var i in test_cases) {
  new Rational(test_cases[i][0], test_cases[i][1]).toDecimal();
}
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:

0 comments

Add a comment