light_stopwatch 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/light_stopwatch.rb +11 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22a5eeaa060856f4bca6b96465ef6677a93fc2fb
|
4
|
+
data.tar.gz: ff506d464102f88a8c7cd9f15e6da8ac99a97b54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 187de824e899ba76fb506d8bbea0959549588088a7afb746d51d2c334fa8c048918ab5c1ee10f5545e3bd9a9ab2d4b6383a6a4b62849f8021e078f9af0e69e0a
|
7
|
+
data.tar.gz: cb877f282709ebbc3f04c0da70994f93ac5e2246ea9495b408304af8211636530c49911e25fd85da8db3d1cac3ea94fe48562d87cec2a848c05eeda72ca5d82c
|
data/lib/light_stopwatch.rb
CHANGED
@@ -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] +=
|
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
|
-
|
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.
|
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-
|
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:
|