micro_bench 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7b61de43614716fc3e48d6661bc4f77524092a7766cd808a5cfdb09e4a70f3b
4
- data.tar.gz: 25deba16810136e20ba13a28dde5b73a63b57a7e639700582b726f9853f8fe9c
3
+ metadata.gz: 7e9068ede1d935d958f8344187512f2dbb8bac9bcf1b0e35a921d95934cbbda6
4
+ data.tar.gz: 55b81809280ad1d3904c3ac00a0547226649d6d77251b71ab57c4584a5070361
5
5
  SHA512:
6
- metadata.gz: 9cdb819b4a60cdc8a7eb958a222217942ff90da5896698af0f2c66b66ed8ccc62f5583241962c0479181aadcf5a098d66505d6a3172dde7246e239d6fffb66f3
7
- data.tar.gz: 6612a374748347f8858cacf36acfa0b712c0d8c93a86242896203558261eb748d49c303aff25602ec89a0f34f08e2c34a67b8a92955e20e59027bb4fac70e363
6
+ metadata.gz: a63891d4771d0cc6747f86abe71766cd239669b5c7d2cbe1da7cee91455ee9d61cf9d0420b077db5550d7cbe5ccb3a3825dbf1e85ff2ba1809042e7e920f0a03
7
+ data.tar.gz: 2b564cd15d145762f9478560c796c38d4b89b018addf00bd2df4faa9bdfe647ff96b02e9f76aa333365442af2af4295d46a68a2ad150191847ee3d49052f677c
@@ -59,15 +59,32 @@ module MicroBench
59
59
  # Identifier of the benchmark
60
60
  #
61
61
  # == Returns:
62
- # Duration of the given benchmark, or nil if benchmark is unknown
62
+ # Formatted duration of the given benchmark, or nil if benchmark is unknown.
63
63
  #
64
64
  # == Example usage:
65
- # MicroBench.stop(:my_benchmark)
65
+ # MicroBench.duration(:my_benchmark)
66
66
  #
67
67
  def duration(bench_id = nil)
68
- configurations.formatter.call(
69
- benchmarks[benchmark_key(bench_id)]&.duration
70
- )
68
+ raw = raw_duration(bench_id)
69
+ return nil if raw.nil?
70
+
71
+ configurations.formatter.call(raw)
72
+ end
73
+
74
+ # Give raw duration of the benchmark
75
+ #
76
+ # == Parameters:
77
+ # bench_id::
78
+ # Identifier of the benchmark
79
+ #
80
+ # == Returns:
81
+ # Duration of the given benchmark, or nil if benchmark is unknown.
82
+ #
83
+ # == Example usage:
84
+ # MicroBench.raw_duration(:my_benchmark)
85
+ #
86
+ def raw_duration(bench_id = nil)
87
+ benchmarks[benchmark_key(bench_id)]&.duration
71
88
  end
72
89
 
73
90
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MicroBench
4
- VERSION = "0.2.3"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -126,4 +126,9 @@ describe MicroBench do
126
126
  described_class.start
127
127
  expect(described_class.duration).to eq "result"
128
128
  end
129
+
130
+ it "gives raw duration" do
131
+ described_class.start
132
+ expect(described_class.raw_duration).to be_a Float
133
+ end
129
134
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micro_bench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyrille Courtière
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug