chronometer 0.1.4 → 0.3.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/command.rb +3 -3
- data/lib/chronometer/dsl.rb +1 -1
- data/lib/chronometer/trace_event.rb +7 -2
- data/lib/chronometer.rb +14 -0
- metadata +16 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82c10102ba6f0c2856260737f932134a8d9941ab6668f5e4df37e4d7c4059d40
|
4
|
+
data.tar.gz: ea1efe1c589e11cb822c0c1d70e5315c90c5860ebaf7ae72b9f130d306c9e23b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c1de9e39bbf2cb4a83ed78cb2e1d88880f42e33682f9712ac7b43453d56fb6bce29402f17b801f9117ac599414e60da3257b5f83403aa64fc117377719421a6
|
7
|
+
data.tar.gz: b1ef3e563eefca11d4251ac8f00eae987dd010b0011e3e74ea8ee6e7a590474844f4dd78f582efdd04e866486c22d30ad78496bc70cda6b58ea1188e8e6731c6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
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
|
data/lib/chronometer/dsl.rb
CHANGED
@@ -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
|
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'
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Giddins
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|
@@ -30,57 +30,57 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.4'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.12'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
68
|
+
version: '3.12'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.56.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
83
|
-
description:
|
82
|
+
version: 1.56.0
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- segiddins@segiddins.me
|
86
86
|
executables:
|
@@ -103,7 +103,7 @@ homepage: https://github.com/segiddins
|
|
103
103
|
licenses:
|
104
104
|
- MIT
|
105
105
|
metadata: {}
|
106
|
-
post_install_message:
|
106
|
+
post_install_message:
|
107
107
|
rdoc_options: []
|
108
108
|
require_paths:
|
109
109
|
- lib
|
@@ -111,16 +111,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
111
|
requirements:
|
112
112
|
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
|
-
version: '2
|
114
|
+
version: '3.2'
|
115
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
|
122
|
-
|
123
|
-
signing_key:
|
121
|
+
rubygems_version: 3.4.10
|
122
|
+
signing_key:
|
124
123
|
specification_version: 4
|
125
124
|
summary: A library that makes generating Chrome trace files for Ruby programs easy.
|
126
125
|
test_files: []
|