interval_timer 0.0.1
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 +7 -0
- data/lib/interval_timer.rb +67 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 68db778f7dea16c6f7b4d8cb24e2012613710174
|
4
|
+
data.tar.gz: 64024c733a6e3da4d634fef795376f937790736b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8462f61e949b2fc11eb22c18651ae81892ced45a57e052887ad5576ef261d59e28a56627fca7c19662b3f6aa3240c6a2b124d1058dda22109671b445b44ae866
|
7
|
+
data.tar.gz: 66f029b9cbfdcdbe62398703c464733652f566a5717d79e53f5b8ab8aac3627c360125034bc34159745273de07eac529d93d6eee1b425c9ae08709f3cd565904
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class IntervalTimer
|
2
|
+
def self.started
|
3
|
+
timer = new
|
4
|
+
timer.start
|
5
|
+
timer
|
6
|
+
end
|
7
|
+
|
8
|
+
def start
|
9
|
+
raise "Already started" if @start_time
|
10
|
+
|
11
|
+
@start_time = Time.now
|
12
|
+
end
|
13
|
+
|
14
|
+
def check_in(message = nil)
|
15
|
+
check_in = build_check_in(message)
|
16
|
+
check_ins.push(check_in)
|
17
|
+
check_in
|
18
|
+
end
|
19
|
+
alias_method :mark, :check_in
|
20
|
+
|
21
|
+
def report
|
22
|
+
[
|
23
|
+
report_header.join("\n"),
|
24
|
+
report_body.join("\n")
|
25
|
+
].join("\n")
|
26
|
+
end
|
27
|
+
|
28
|
+
def check_ins
|
29
|
+
@check_ins ||= []
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def build_check_in(message)
|
35
|
+
{ created_at: Time.now, message: message }
|
36
|
+
end
|
37
|
+
|
38
|
+
def report_header
|
39
|
+
output = []
|
40
|
+
|
41
|
+
output << "start_time: #{@start_time}"
|
42
|
+
|
43
|
+
output
|
44
|
+
end
|
45
|
+
|
46
|
+
def report_body
|
47
|
+
output = []
|
48
|
+
|
49
|
+
check_ins.each_with_index do |x, i|
|
50
|
+
last = i == 0 ? nil : check_ins[i - 1]
|
51
|
+
|
52
|
+
output.push report_line(x, last)
|
53
|
+
end
|
54
|
+
|
55
|
+
output
|
56
|
+
end
|
57
|
+
|
58
|
+
def report_line(x, last)
|
59
|
+
if last
|
60
|
+
since_last = x[:created_at] - last[:created_at]
|
61
|
+
else
|
62
|
+
since_last = x[:created_at] - @start_time
|
63
|
+
end
|
64
|
+
|
65
|
+
"#{x[:created_at]} -- #{ since_last.round(3) } -- #{x[:message]}"
|
66
|
+
end
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: interval_timer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luke Griffiths
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Code profiling tool that lets you track how long things take. Start a
|
42
|
+
timer and check in from points in your code. Prints a report of the time elapsed
|
43
|
+
between those points in the code.
|
44
|
+
email: lgcboulder@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- lib/interval_timer.rb
|
50
|
+
homepage: https://rubygems.org/gems/interval_timer
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.4.5
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Code profiling tool that lets you track how long things take.
|
74
|
+
test_files: []
|