hotch 0.0.2 → 0.0.3
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 +4 -4
- data/lib/hotch.rb +28 -13
- data/lib/hotch/monkey_patches.rb +7 -0
- data/lib/hotch/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61f71a4ba3bef064a412f8b79c1932a84e0a1316
|
4
|
+
data.tar.gz: 59554006ec68fe65bae953d22a85462ec5d766e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29420bf9b209a0d2a989763f24549844d3aa86d7a71420e92e48309aa213cd6357071031b9df6a936f8cfaa5e02fe16a31fa422db4a2f325f4cdb159c5f33821
|
7
|
+
data.tar.gz: 2d9589beac8841df9e8b1e8b9992308310ec3dd142e33a24a53e80a1826a5b92554ad1941d55f72e9526054077fda658ba5f30b7baf174264153b333783b0bdf
|
data/lib/hotch.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'stackprof'
|
2
2
|
require 'tmpdir'
|
3
3
|
|
4
|
+
require 'hotch/monkey_patches'
|
5
|
+
|
4
6
|
class Hotch
|
5
7
|
attr_reader :name
|
6
8
|
|
@@ -35,23 +37,14 @@ class Hotch
|
|
35
37
|
report = @reports.inject(:+) or return
|
36
38
|
|
37
39
|
dir = Dir.mktmpdir("hotch.#{name}.")
|
38
|
-
dump = File.open(File.join(dir, "profile.dump"), "wb")
|
39
|
-
svg = File.join(File.join(dir, "profile.svg"))
|
40
|
-
|
41
|
-
|
42
|
-
report.print_graphviz(nil, dump)
|
43
|
-
|
44
|
-
dump.close
|
45
40
|
|
46
|
-
|
41
|
+
report_dump(report, dir, "profile.dump")
|
42
|
+
dot = report_dot(report, dir, "profile.dot")
|
43
|
+
svg = convert_svg(dir, dot, "profile.svg")
|
47
44
|
|
48
45
|
yield svg
|
49
46
|
end
|
50
47
|
|
51
|
-
def system!(*args)
|
52
|
-
Kernel.system(*args) or raise "system call failed: #{args.join(' ')}"
|
53
|
-
end
|
54
|
-
|
55
48
|
def report_at_exit(viewer=ENV['HOTCH_VIEWER'])
|
56
49
|
return if defined? @at_exit_installed
|
57
50
|
|
@@ -62,7 +55,7 @@ class Hotch
|
|
62
55
|
puts "Profile SVG: #{svg}"
|
63
56
|
|
64
57
|
if viewer
|
65
|
-
system viewer, svg
|
58
|
+
Kernel.system viewer, svg
|
66
59
|
end
|
67
60
|
end
|
68
61
|
end
|
@@ -75,6 +68,28 @@ class Hotch
|
|
75
68
|
def name
|
76
69
|
@name.gsub(/\W+/, '_')
|
77
70
|
end
|
71
|
+
|
72
|
+
def report_dump(report, dir, file)
|
73
|
+
path = File.join(dir, file)
|
74
|
+
File.open(path, 'wb') do |fh|
|
75
|
+
report.print_dump(fh)
|
76
|
+
end
|
77
|
+
path
|
78
|
+
end
|
79
|
+
|
80
|
+
def report_dot(report, dir, file)
|
81
|
+
path = File.join(dir, file)
|
82
|
+
File.open(path, 'wb') do |fh|
|
83
|
+
report.print_graphviz(nil, fh)
|
84
|
+
end
|
85
|
+
path
|
86
|
+
end
|
87
|
+
|
88
|
+
def convert_svg(dir, dot, file)
|
89
|
+
svg = File.join(dir, file)
|
90
|
+
system("dot", "-Tsvg", "-o", svg, dot) or raise "dot failed"
|
91
|
+
svg
|
92
|
+
end
|
78
93
|
end
|
79
94
|
|
80
95
|
def Hotch(aggregate: true)
|
data/lib/hotch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Suschlik
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- examples/simple.rb
|
68
68
|
- hotch.gemspec
|
69
69
|
- lib/hotch.rb
|
70
|
+
- lib/hotch/monkey_patches.rb
|
70
71
|
- lib/hotch/run.rb
|
71
72
|
- lib/hotch/version.rb
|
72
73
|
homepage: https://github.com/splattael/hotch
|