Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super slow #6

Closed
ridiculous opened this issue Jan 25, 2017 · 2 comments
Closed

Super slow #6

ridiculous opened this issue Jan 25, 2017 · 2 comments

Comments

@ridiculous
Copy link

This is a cool gem, but it's super slow compared to alternatives. Are there plans to improve on that?

Here is a simple benchmark against memo-it and memoist

require 'benchmark/ips'
module Go
  extend Memoist
  extend self

  def go_memo_it
    memo { false }
  end

  def go_memoist
    false
  end

  memoize :go_memoist
end

Benchmark.ips do |x|
  x.warmup = 3
  x.time = 10
  x.report('memo-it') { Go.go_memo_it }
  x.report('memoist') { Go.go_memoist }
end

=begin
Warming up --------------------------------------
             memo-it    16.623k i/100ms
             memoist   127.203k i/100ms
Calculating -------------------------------------
             memo-it    185.206k (± 7.1%) i/s -      1.845M in  10.010942s
             memoist      2.252M (± 6.8%) i/s -     22.515M in  10.044946s
end
@phoet
Copy link
Owner

phoet commented Jan 25, 2017

thanks for the benchmark.

due to the overhead of generating the memoization key, it will always be slower than monkeypatching ruby methods.

i don't know if the term 'super slow' is appropriate thought. it's meant for optimizing 3rd party calls like http, which are really slow, like magnitudes more slowly.

if you are looking for a hot spot code optimization, this is not for you.

@phoet phoet closed this as completed Jan 25, 2017
@ridiculous
Copy link
Author

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants