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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d84039cc27281efe5fc1b3b062c7fb44a3acdb4a3177d6564369dffb70548b7f
4
- data.tar.gz: 235119fe07373d79234c5cab465c22a6e665c3f20bb44a685035db8be263ee33
3
+ metadata.gz: 54dcb45bb4747eabd437020410fd5dbd9f5896ab882f461cf28677301be6c8f8
4
+ data.tar.gz: 324faf267e419bff7989ee9546c4dcab872db66c75e82a6c4abe309ecce312c4
5
5
  SHA512:
6
- metadata.gz: c62218e8bc5fc0c89ff8171510aced382b25668d1226fb7912d0c24d3492004cb153e219df4b8e7e94e900b2d0cd3203c5de2040a200bb674c4a8d8a6d47ba1b
7
- data.tar.gz: b5877c5ac18428dc93f672181fb569bf7169a8301c1f0fad3c1a072307cd953de12e660a350a0eb42420e0a3b31637aa53c3275d46c618521be80f2ca40142b7
6
+ metadata.gz: a52fc0d36cb3a9425cd45cbf472c3ff1cbf35da32bfd5a600c5f196f4ba8c96f8a255fa40a08519e3a26d1401dc86a373cf1282d8cf999d96539e0ff8ddda78d
7
+ data.tar.gz: d0055fc487156a18c77c1dd55090326f026c0a3301225026ecadd33d57e900ce8f52de970ab89e5f71f4234061e25f3e2c5e544de1b385a5f131a3dceab27e4b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.2.0
@@ -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'
@@ -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 ||= File.join(e, @file_to_load)
45
- a &&= nil unless File.file?(a)
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.1.4
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-03-28 00:00:00.000000000 Z
11
+ date: 2018-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide