yuslow 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30c27065a08a4b7140a74cf6aa520a5785648d21516ebc45e80ccaad063df9b0
4
- data.tar.gz: 3e664aeffaee96cdc09632ae470df633976e0f811c4f5cde6a16a560aab190ef
3
+ metadata.gz: 676d25fa230b9eed3bd3f674cb4a33641748034d0bab29ded6c7be35651c7014
4
+ data.tar.gz: 844a69e4bd5eaaad8ff7f2686ccce43a11a8c68490418659273c591b57ae357d
5
5
  SHA512:
6
- metadata.gz: adf2247d500446139937b95b7f663caac86cfada0be0a2ba57241e48e149cd9751b8df41608911675f40252965ff01053b8780add96433e5b137d245e8fb586e
7
- data.tar.gz: ccd64c90d53730765d6e62c6c86bb2a75e33dae05ea212f07d06722cd06eb49f027a61f512fd85f7356efc4d8a937d04c60346c5125beba4e5e451df8b9806bb
6
+ metadata.gz: 4a85832af47a70ad676c382b6de75b74f67ecb3b3407b0e59c9387b4c92ab9a05aec28977e53845f689db4b75205111dd2f2a5f2c0e1b2b48d996343f0fcd900
7
+ data.tar.gz: 568902762d45633c06185df84ab58d3473947050d52ae58069f31c050e598901819608f2c8bd1e40870fc65c725da803ff5a6ec74a830ef1d4dcc28a65620953
data/README.md CHANGED
@@ -47,5 +47,5 @@ Thread[1]:
47
47
  | Parameter | Options | Default | Description |
48
48
  |---------------|-------------------|-----------|-----------------------------------------------------|
49
49
  | **output** | `false` `:stdout` | `:stdout` | Defines how the profiling results will be presented |
50
- | **max_level** | `number`, `nil` | `nil` | Specifies maximum profiling depth |
51
- | **debug** | `true` `false` | false | Prints debug information while profiling |
50
+ | **max_level** | `number` `nil` | `nil` | Specifies maximum profiling depth |
51
+ | **debug** | `true` `false` | `false` | Prints debug information while profiling |
@@ -10,7 +10,6 @@ module Yuslow
10
10
  @debug = debug
11
11
  @tracing = false
12
12
  @trace = nil
13
- @depth = 0
14
13
  @max_depth = max_depth
15
14
  @execution = {}
16
15
  end
@@ -18,15 +17,19 @@ module Yuslow
18
17
  def start
19
18
  @trace = TracePoint.new(:call, :return, :c_call, :c_return) do |trace_point|
20
19
  thread_id = Thread.current.object_id
21
- @execution[thread_id] ||= {root: nil, current: nil}
20
+ @execution[thread_id] ||= {root: nil, current: nil, depth: 0}
22
21
 
23
- if trace_point.defined_class == self.class && trace_point.callee_id == :start
24
- @tracing = true
25
- elsif trace_point.defined_class == self.class && trace_point.callee_id == :finish
26
- @tracing = false
22
+ if trace_point.defined_class == self.class
23
+ if trace_point.callee_id == :start
24
+ @tracing = true
25
+ elsif trace_point.callee_id == :finish
26
+ @tracing = false
27
+ else
28
+ raise "Unexpected method #{trace_point.callee_id} called on #{self.class}"
29
+ end
27
30
  elsif @tracing
28
31
  if %i(call c_call).include?(trace_point.event)
29
- if @depth < @max_depth
32
+ if !@max_depth || @execution[thread_id][:depth] < @max_depth
30
33
  if @execution[thread_id][:current]
31
34
  @execution[thread_id][:current] = @execution[thread_id][:current].fork object: trace_point.defined_class,
32
35
  method: trace_point.callee_id
@@ -35,17 +38,20 @@ module Yuslow
35
38
  @execution[thread_id][:root] = operation
36
39
  @execution[thread_id][:current] = operation
37
40
  end
38
- end
39
41
 
40
- debug trace_point, @depth
41
- @depth += 1
42
+ debug trace_point, @execution[thread_id][:depth]
43
+ @execution[thread_id][:depth] += 1
44
+ end
42
45
  elsif %i(return c_return).include? trace_point.event
43
- @depth -= 1
44
- debug trace_point, @depth
46
+ if @execution[thread_id][:current]&.identifier == "#{trace_point.defined_class}##{trace_point.callee_id}"
47
+ @execution[thread_id][:depth] -= 1
45
48
 
46
- if @depth < @max_depth
47
- @execution[thread_id][:current]&.complete
48
- @execution[thread_id][:current] = @execution[thread_id][:current]&.parent
49
+ if !@max_depth || @execution[thread_id][:depth] < @max_depth
50
+ debug trace_point, @execution[thread_id][:depth]
51
+
52
+ @execution[thread_id][:current]&.complete
53
+ @execution[thread_id][:current] = @execution[thread_id][:current]&.parent
54
+ end
49
55
  end
50
56
  end
51
57
  end
@@ -72,7 +78,7 @@ module Yuslow
72
78
  operations =
73
79
  @execution.keys.map do |thread_id|
74
80
  @execution[thread_id][:root]
75
- end
81
+ end.compact
76
82
 
77
83
  printer.execute operations
78
84
  end
@@ -28,7 +28,7 @@ module Yuslow
28
28
  output << "#{indentation}#{identifier} elapsed #{elapsed} ms"
29
29
  else
30
30
  text = "#{operation.identifier} did not finish"
31
- colorize(text, :red) if colorize
31
+ colorize(text, :yellow) if colorize
32
32
 
33
33
  output << "#{indentation}#{text}"
34
34
  end
@@ -46,6 +46,7 @@ module Yuslow
46
46
  when :black then '30'
47
47
  when :red then '31'
48
48
  when :green then '32'
49
+ when :yellow then '33'
49
50
  when :white then '1;37'
50
51
  when :bg_black then '40'
51
52
  when :bg_red then '41'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yuslow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deyan Dobrinov