Comments (9)
Ah from the linked PR you actually used 1ms.
Then it might be more realistic to fix this, although I don't remember the details.
Not sure how it's possible we get 0 samples, should be at least one.
from benchmark-ips.
Huh! Out of curiosity, benchmark-ips also isn't very happy if the test time is too short:
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'benchmark-ips'
end
Benchmark.ips do |x|
x.config(:warmup => 1, :time => 0.000000001)
x.report("addition") { 1 + 2 }
x.compare!
end
result:
$ ruby bench-ips-testcase.rb
Warming up --------------------------------------
addition 2.741M i/100ms
Calculating -------------------------------------
additionTraceback (most recent call last):
11: from bench-ips-testcase.rb:9:in `<main>'
10: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips.rb:53:in `ips'
9: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips/job.rb:254:in `run'
8: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips/job.rb:254:in `times'
7: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips/job.rb:255:in `block in run'
6: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips/job.rb:312:in `run_benchmark'
5: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips/job.rb:312:in `each'
4: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips/job.rb:351:in `block in run_benchmark'
3: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips/job.rb:367:in `create_stats'
2: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips/job.rb:367:in `new'
1: from /Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/ips/stats/sd.rb:11:in `initialize'
/Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/benchmark-ips-2.9.2/lib/benchmark/timing.rb:12:in `mean': undefined method `/' for nil:NilClass (NoMethodError)
To add context on why anyone would want to run a "benchmark" with low warmup (and low time), it's because we run benchmarks separately from our usual test suite, and it happened in the past that we broke our benchmarks but CI was still green.
So now we run the benchmarks for a really short time in CI just to validate that they're working, and get faster feedback when we broke them.
from benchmark-ips.
That warmup is 0.1ns and the time 1ns, it's basically impossible to measure such small times, i.e., clock_gettime actually takes longer to run.
Do you still get the error if you use something more reasonable like 1ms?
from benchmark-ips.
Yup, we were using 1ms, I'm guessing because of noisy neighbors (container inside VM inside possibly-shared-CI-machine) we got unlucky from time to time.
I reduced it a lot in the example to trigger it with certainty.
I suspect the issue may come from
benchmark-ips/lib/benchmark/ips/job.rb
Lines 275 to 281 in ecc3a7d
target
is small enough, then by the time it gets to the check, time's over, and the loop never runs.from benchmark-ips.
Makes sense to fix. Agreed that "we should get at least one sample" is a common-sense fix here.
from benchmark-ips.
That looks like a bug in the code I added there, whoops.
I can try to make a PR but I'm not sure when I'll have time.
If anyone else want to fix it I'm happy to review.
from benchmark-ips.
Fix in #121
from benchmark-ips.
Also for your use case and with that fix, x.config(warmup: 0, time: 0)
is probably the best because that runs a single iteration, a non-zero warmup means at least 2 iterations total.
from benchmark-ips.
Also for your use case and with that fix, x.config(warmup: 0, time: 0) is probably the best because that runs a single iteration, a non-zero warmup means at least 2 iterations total.
👍 Thanks for the tip and thanks for the fix :)
from benchmark-ips.
Related Issues (20)
- NoMethodError: gem install --user-install benchmark-ips -v 2.8.0 HOT 9
- Missing file benchmark/ips/stats/stats_metric HOT 2
- Files missing from gem HOT 1
- Please update history.txt HOT 1
- Can we add a v2.8.2 tag? HOT 1
- benchmark.fyi link in README.md is pointing to a ArcGIS instance HOT 8
- Don't print error when printing standard deviation in comparison HOT 4
- Suite Only Availabe via config HOT 2
- Slow Tests HOT 1
- `cannot load such file -- benchmark/ips/noop_suite` HOT 3
- Parameterize width?
- Add Q&D driver method HOT 4
- Fork support? HOT 2
- How to benchmark sequentially? HOT 6
- Calculation is stuck HOT 1
- When there is variable setup time HOT 12
- Fully Automatic Mode HOT 5
- Add factor to control times parameter HOT 1
- Release new gem version HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from benchmark-ips.