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

Performance drop in 0.2.6 #28

Open
janlelis opened this issue Apr 14, 2015 · 2 comments
Open

Performance drop in 0.2.6 #28

janlelis opened this issue Apr 14, 2015 · 2 comments

Comments

@janlelis
Copy link
Contributor

First of all, thank you a lot for this great gem. Being inspired, I build a very similar one, with some differences in syntax and features. While doing so, I noticed a huge performance drop in the latest version of rubype.

Here is a benchmark using rubype 0.2.5:

ruby version: 2.2.1
sig version: 1.0.0
rubype version: 0.2.5
contracts version: 0.8
Calculating -------------------------------------
                pure    57.194k i/100ms
                 sig     7.816k i/100ms
              rubype     8.756k i/100ms
           contracts     5.771k i/100ms
-------------------------------------------------
                pure      2.855M (± 1.1%) i/s -     14.299M
                 sig    102.990k (± 2.5%) i/s -    515.856k
              rubype    116.062k (± 1.0%) i/s -    586.652k
           contracts     70.575k (± 1.7%) i/s -    357.802k

Comparison:
                pure:  2854866.4 i/s
              rubype:   116062.3 i/s - 24.60x slower
                 sig:   102990.1 i/s - 27.72x slower
           contracts:    70575.3 i/s - 40.45x slower

And here one using rubype 0.2.6:

ruby version: 2.2.1
sig version: 1.0.0
rubype version: 0.2.6
contracts version: 0.8
Calculating -------------------------------------
                pure    53.905k i/100ms
                 sig     7.808k i/100ms
              rubype   417.000  i/100ms
           contracts     5.699k i/100ms
-------------------------------------------------
                pure      2.956M (± 2.4%) i/s -     14.770M
                 sig    105.957k (± 0.5%) i/s -    530.944k
              rubype      4.313k (± 5.3%) i/s -     21.684k
           contracts     69.450k (± 2.3%) i/s -    347.639k

Comparison:
                pure:  2956225.5 i/s
                 sig:   105956.8 i/s - 27.90x slower
           contracts:    69450.1 i/s - 42.57x slower
              rubype:     4312.8 i/s - 685.45x slower

The code used for the benchmark: https://github.com/janlelis/sig/blob/v1.0.0/Rakefile#L32-L131

@jonatack
Copy link

Interesting 👍

You might consider using the times form for benchmark-ips, shown below (reproduced from the readme). The results when operations are small are often different:

  # To reduce overhead, the number of iterations is passed in
  # and the block must run the code the specific number of times.
  # Used for when the workload is very small and any overhead
  # introduces incorrectable errors.

  x.report("addition2") do |times|
    i = 0
    while i < times
      1 + 2
      i += 1
    end
  end

@gogotanaka
Copy link
Owner

@janlelis hi! Looking at your great gem sig, I'm inspired as well. Sig has many interesting features or implementations which Rubype doesn't have.
I'm gonna steal some of them ;)

Aside from that, thank for letting me know about this issue, I found this line causes performance drop.
https://github.com/gogotanaka/Rubype/blob/develop/lib/rubype.rb#L14

By assigning result of Kernel#caller to a variable, made it twice faster but it's still slow...

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

3 participants