light_stopwatch 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/light_stopwatch.rb +11 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73f3e5091ed44bf0ba0fb08d4b67e5f13cda7ef2
4
- data.tar.gz: 7e13d8e5d9a248a3a100d3b153d0f34b2c3929ea
3
+ metadata.gz: 22a5eeaa060856f4bca6b96465ef6677a93fc2fb
4
+ data.tar.gz: ff506d464102f88a8c7cd9f15e6da8ac99a97b54
5
5
  SHA512:
6
- metadata.gz: 39beca2c9176eba42a00c4442a83ecb4e25577fbfa7747174e3e8ed8243afc3115856d91d230c654fd1511e03980124a75048441025bac5af6c2ab30136edb28
7
- data.tar.gz: ae11be066ebd31418a833aaccf4a7d64bbc98c0e3631ef96081c59827f53049378d7157371f21d5cf2ae6fe0e4e35df79d5186e65434dd47c79c3ba8576f73db
6
+ metadata.gz: 187de824e899ba76fb506d8bbea0959549588088a7afb746d51d2c334fa8c048918ab5c1ee10f5545e3bd9a9ab2d4b6383a6a4b62849f8021e078f9af0e69e0a
7
+ data.tar.gz: cb877f282709ebbc3f04c0da70994f93ac5e2246ea9495b408304af8211636530c49911e25fd85da8db3d1cac3ea94fe48562d87cec2a848c05eeda72ca5d82c
@@ -9,8 +9,12 @@ class LightStopwatch
9
9
  def self.agg(key, &block)
10
10
  @@ls_aggs[key] ||= agg_template
11
11
 
12
+ results = get_time(&block)
13
+
12
14
  @@ls_aggs[key][:count] += 1
13
- @@ls_aggs[key][:value] += get_time(&block)
15
+ @@ls_aggs[key][:value] += results[:took]
16
+
17
+ results[:retval]
14
18
  end
15
19
 
16
20
  def self.get_aggs
@@ -31,14 +35,17 @@ class LightStopwatch
31
35
 
32
36
  def self.get_time(&block)
33
37
  start = Time.now
34
- yield
38
+ retval = yield
35
39
  stop = Time.now
36
40
 
37
- stop - start
41
+ {took: (stop - start), retval: retval}
38
42
  end
39
43
 
40
44
  def self.measure(tag = DEFAULT_TAG, &block)
41
- puts "#{tag} #{get_time(&block)}"
45
+ results = get_time(&block)
46
+ puts "#{tag} #{results[:took]}"
47
+
48
+ results[:retval]
42
49
  end
43
50
 
44
51
  def self.reset
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: light_stopwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Renra Gloser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: '["Measure the execute time of anything that you pass in a block"]'
14
14
  email: