Preliminary submission - std.rational and std.typelist

Arlen arlen.ng at gmx.com
Wed Feb 13 11:37:54 PST 2013


On Mon, Feb 11, 2013 at 1:05 PM, bearophile <bearophileHUGS at lycos.com>wrote:

>
>
> And isn't it better for the Rational constructor to simplify the arguments
> (calling an optimized GCD)? See this implementation (that doesn't use an
> optimized GCD):
>
> http://rosettacode.org/wiki/**Arithmetic/Rational#D<http://rosettacode.org/wiki/Arithmetic/Rational#D>
>
> Bye,
> bearophile
>

I ran some benchmarks, and I don't see how the rosetta version is more
optimized:  https://gist.github.com/Arlen/4947368

And the results on my 64-bit system, compiled with '-O -inline -release':

  Rosetta            rational + rational: 3333 ms
 Rosetta immutable  rational + rational: 3358 ms
 std                rational + rational: 2348 ms
 std immutable      rational + rational: 2197 ms

 Rosetta            rational - rational: 2822 ms
 Rosetta immutable  rational - rational: 2720 ms
 std                rational - rational: 1668 ms
 std immutable      rational - rational: 1583 ms

 Rosetta            rational * rational: 1628 ms
 Rosetta immutable  rational * rational: 1579 ms
 std                rational * rational: 1603 ms
 std immutable      rational * rational: 1500 ms

 Rosetta            rational / rational: 1636 ms
 Rosetta immutable  rational / rational: 1614 ms
 std                rational / rational: 1664 ms
 std immutable      rational / rational: 1534 ms

 Rosetta            rational == rational: 180 ms
 Rosetta immutable  rational == rational: 176 ms
 std                rational == rational: 90 ms
 std immutable      rational == rational: 80 ms

Arlen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130213/91b57b6a/attachment-0001.html>


More information about the Digitalmars-d mailing list