chronometer 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/chronometer.rb +14 -0
- data/lib/chronometer/command.rb +3 -3
- data/lib/chronometer/trace_event.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54dcb45bb4747eabd437020410fd5dbd9f5896ab882f461cf28677301be6c8f8
|
4
|
+
data.tar.gz: 324faf267e419bff7989ee9546c4dcab872db66c75e82a6c4abe309ecce312c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a52fc0d36cb3a9425cd45cbf472c3ff1cbf35da32bfd5a600c5f196f4ba8c96f8a255fa40a08519e3a26d1401dc86a373cf1282d8cf999d96539e0ff8ddda78d
|
7
|
+
data.tar.gz: d0055fc487156a18c77c1dd55090326f026c0a3301225026ecadd33d57e900ce8f52de970ab89e5f71f4234061e25f3e2c5e544de1b385a5f131a3dceab27e4b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/chronometer.rb
CHANGED
@@ -34,6 +34,20 @@ class Chronometer
|
|
34
34
|
nil
|
35
35
|
end
|
36
36
|
|
37
|
+
def associate_sub_slices!
|
38
|
+
parents = []
|
39
|
+
@trace_events.each do |event|
|
40
|
+
case event.event_type
|
41
|
+
when :B
|
42
|
+
parents << event
|
43
|
+
when :E
|
44
|
+
parent = parents.pop
|
45
|
+
event.sub_slices.replace parent.sub_slices if parent
|
46
|
+
parents.last.sub_slices << event unless parents.empty?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
37
51
|
def print_trace_event_report(dest, metadata: {})
|
38
52
|
raise ArgumentError, 'cannot manually specify :traceEvents' if metadata.key?(:traceEvents)
|
39
53
|
require 'json'
|
data/lib/chronometer/command.rb
CHANGED
@@ -39,10 +39,10 @@ class Chronometer
|
|
39
39
|
help!("No such chronofile `#{@chronofile}`")
|
40
40
|
end
|
41
41
|
help! 'Must supply a ruby file to load' unless @file_to_load
|
42
|
-
@file_to_load = ENV.fetch('PATH', '').split(File::PATH_SEPARATOR).push('.').reduce do |a, e|
|
42
|
+
@file_to_load = ENV.fetch('PATH', '').split(File::PATH_SEPARATOR).push('.').reduce(nil) do |a, e|
|
43
43
|
next a if a
|
44
|
-
a
|
45
|
-
|
44
|
+
a = File.join(e, @file_to_load)
|
45
|
+
next nil unless File.file?(a)
|
46
46
|
a
|
47
47
|
end
|
48
48
|
help! "Could not find `#{@file_to_load}`" unless @file_to_load
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
class Chronometer
|
4
4
|
class TraceEvent
|
5
|
-
attr_reader :process_id, :thread_id, :start_time_usec, :event_type, :name, :args, :category, :duration, :cls, :method
|
5
|
+
attr_reader :process_id, :thread_id, :start_time_usec, :event_type, :name, :args, :category, :duration, :cls, :method, :sub_slices
|
6
6
|
|
7
|
-
def initialize(process_id: nil, thread_id: nil, start_time_usec: nil, event_type: nil, name: nil, args: nil, category: nil, duration: nil, cls: nil, method: nil)
|
7
|
+
def initialize(process_id: nil, thread_id: nil, start_time_usec: nil, event_type: nil, name: nil, args: nil, category: nil, duration: nil, cls: nil, method: nil, sub_slices: [])
|
8
8
|
@process_id = process_id
|
9
9
|
@thread_id = thread_id
|
10
10
|
@start_time_usec = start_time_usec
|
@@ -15,6 +15,7 @@ class Chronometer
|
|
15
15
|
@duration = duration
|
16
16
|
@cls = cls
|
17
17
|
@method = method
|
18
|
+
@sub_slices = sub_slices
|
18
19
|
end
|
19
20
|
|
20
21
|
def to_h
|
@@ -30,6 +31,10 @@ class Chronometer
|
|
30
31
|
)
|
31
32
|
end
|
32
33
|
|
34
|
+
def self_time
|
35
|
+
sub_slices.reduce(duration) { |a, e| a - e.duration }
|
36
|
+
end
|
37
|
+
|
33
38
|
if {}.respond_to?(:compact)
|
34
39
|
def compact_hash(hash)
|
35
40
|
hash.compact
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chronometer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Giddins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|