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

Add a way to specify a control report #13

Open
davy opened this issue Nov 4, 2014 · 0 comments
Open

Add a way to specify a control report #13

davy opened this issue Nov 4, 2014 · 0 comments

Comments

@davy
Copy link
Owner

davy commented Nov 4, 2014

For some reports, a control report would be nice to be able to separate out expensive, shared behavior.

For example, the 'dup' report in this benchmark:

report = Benchmark.bigo do |x|

  x.generator {|size|
    (0...size).each_with_object({}) do |i, h|
      h[i] = SecureRandom.hex
    end
  }

  # dup acts as a control for this test
  # because merge! modifies the existing hash,
  # the hash needs to be duped in order to test
  # appropriately
  #
  # this means that to control for this work in the
  # other reports, the hash must also be duped, even
  # for merge where the original hash is not modified
  x.report("dup") { |items, size|
    items.dup
  }
  x.report("merge") { |items, size|
    items.dup.merge(rand(size) => SecureRandom.hex)
  }
  x.report("merge!") { |items, size|
    items.dup.merge!(rand(size) => SecureRandom.hex)
  }
  x.report("set") { |items, size|
    items.dup[rand(size)] = SecureRandom.hex
  }
end

In this case, if the expense of the 'dup' report were then subtracted from the results of the other reports, a cleaner view of the differences in behavior would be possible.

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

No branches or pull requests

1 participant