SciRuby / statsample

A suite for basic and advanced statistics on Ruby.
https://github.com/sciruby/statsample
BSD 3-Clause "New" or "Revised" License
95 stars 29 forks source link

fix [].mean method #45

Closed IsmailM closed 8 years ago

IsmailM commented 8 years ago

Fixes #44

mikecmpbll commented 8 years ago

this is really petty but I've always preferred 1.fdiv(2) over 1.to_f/2 and it's faster too.

require 'benchmark/ips'
Benchmark.ips do |x|
  x.report('fdiv') { 1.fdiv(2) }
  x.report('to_f') { 1.to_f/2 }
  x.compare!
end
Calculating -------------------------------------
                fdiv    65.294k i/100ms
                to_f    64.008k i/100ms
-------------------------------------------------
                fdiv      5.545M (± 7.3%) i/s -     27.554M
                to_f      4.186M (± 6.0%) i/s -     20.867M

Comparison:
                fdiv:  5545234.9 i/s
                to_f:  4186422.3 i/s - 1.32x slower

shrugs :neckbeard: :grin:

IsmailM commented 8 years ago

Thanks @mikecmpbll - I’ve never come across fdiv before…

Anyways. Done.

IsmailM commented 8 years ago

@mikecmpbll

Using fdiv makes travis sad… Any idea why?

to_f = https://travis-ci.org/SciRuby/statsample/builds/86715122 (passing) fdiv = https://travis-ci.org/SciRuby/statsample/builds/86722385 (failing)

Shall I change back to to_f

mikecmpbll commented 8 years ago

weird?? :/ didn't mean to cause an issue here. i can look into why this fails tomorrow, but up to you guys.

IsmailM commented 8 years ago

Thanks

Could just be a hiccup from Travis; Can someone (with the permissions) restart this build - perhaps it will ‘automagically’ fix things.

IsmailM commented 8 years ago

Okay, the build now passes...

mikecmpbll commented 8 years ago

:+1: :wink:

v0dro commented 8 years ago

Could you please rebase this feature into a single commit?

IsmailM commented 8 years ago

@v0dro, as requested, this has now been rebased into a single commit.

agarie commented 8 years ago

Thanks @IsmailM!