hotch 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 38cc02398ab2755f8c90da8ae6ea973db46de9b7
4
- data.tar.gz: 938117da7ad53717ba52d5507c9b4b8575317068
3
+ metadata.gz: 61f71a4ba3bef064a412f8b79c1932a84e0a1316
4
+ data.tar.gz: 59554006ec68fe65bae953d22a85462ec5d766e8
5
5
  SHA512:
6
- metadata.gz: 91eaa4af1f66add4591182e39b47192325b5842e7bb87176aba19491e071880394d6421288590943683f2103e970e143f07bd535b3eb758fc393ba1919187f17
7
- data.tar.gz: 485b40654f50784ec3e08483fac13b4b01b41fefa47790e8d25abf9cf99d32ab720f49169517cda9b662de3ddd72128415c52054b28f1c0850b2313be4e1a8c2
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
- system! "dot", "-Tsvg", "-o", svg, dump.path
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)
@@ -0,0 +1,7 @@
1
+ # Monkey patches
2
+
3
+ StackProf::Report.class_eval do
4
+ def print_dump(f = STDOUT)
5
+ f.puts Marshal.dump(@data.reject{|k,v| k == :files })
6
+ end
7
+ end
data/lib/hotch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hotch
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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