SHOW:
|
|
- or go back to the newest paste.
1 | require 'benchmark' | |
2 | ||
3 | module BenchmarkHelpers | |
4 | def benchmark(description, &block) | |
5 | # 1. Nope | |
6 | #bm_proc = Proc.new do | |
7 | # db = Proc.new { |bm| bm.report(description, &block) } | |
8 | # Benchmark.bm(description.length, &db) | |
9 | #end | |
10 | it description do | |
11 | Benchmark.bm(description.length) do |bm| | |
12 | # 2. Nada | |
13 | #bm.report description, &block | |
14 | bm.report description do | |
15 | # 3. Zilch | |
16 | block.yield | |
17 | end | |
18 | end | |
19 | end | |
20 | end | |
21 | end | |
22 | ||
23 | RSpec.configure do |c| | |
24 | c.extend BenchmarkHelpers | |
25 | end | |
26 | ||
27 | describe "scopes" do | |
28 | - | benchmark "how do they work" do |
28 | + | it "succeeds" do |
29 | true.should == true # success | |
30 | true.should be # success | |
31 | end | |
32 | benchmark "throws exception on 'be'" do | |
33 | true.should == true # success | |
34 | true.should be # exception | |
35 | end | |
36 | end | |
37 | ||
38 | ||
39 | rake spec SPEC=spec/benchmark_spec.rb | |
40 | /home/aaron/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S bundle exec rspec spec/benchmark_spec.rb | |
41 | ||
42 | scopes | |
43 | user system total real | |
44 | how do they work how do they work (FAILED - 1) | |
45 | ||
46 | Failures: | |
47 | ||
48 | 1) scopes how do they work | |
49 | Failure/Error: true.should be | |
50 | NameError: | |
51 | undefined local variable or method `be' for RSpec::Core::ExampleGroup::Nested_1:Class | |
52 | # ./spec/benchmark_spec.rb:25:in `block (2 levels) in <top (required)>' | |
53 | # ./spec/benchmark_spec.rb:12:in `yield' | |
54 | # ./spec/benchmark_spec.rb:12:in `block (3 levels) in benchmark' | |
55 | # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:295:in `measure' | |
56 | # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:382:in `item' | |
57 | # ./spec/benchmark_spec.rb:11:in `block (2 levels) in benchmark' | |
58 | # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:178:in `benchmark' | |
59 | # /home/aaron/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:208:in `bm' | |
60 | # ./spec/benchmark_spec.rb:10:in `block in benchmark' |