analyzer 1.0.1 → 1.0.5

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
- SHA1:
3
- metadata.gz: 51beba34588f8acce4c871ade9f58bb256630d65
4
- data.tar.gz: fe3874d888ca0cf952486c7570720c38e73a872f
2
+ SHA256:
3
+ metadata.gz: 796165e7b6c23de07d5176ae67c8cd9aa7dc8266afa35164fd243e47ca3a9725
4
+ data.tar.gz: 39a312f376d0254f9643672a54a5a7927c379c84e74e020fae6a2c06775e25a1
5
5
  SHA512:
6
- metadata.gz: 19017d89459ce25bdc071b8299c0b4c0d934dcb17e67d5d9efd5cd86aae105268813e06a6e82758ceb1fbde6b836d9e24ac3fdb8604496f73e3fb1982ef4dac3
7
- data.tar.gz: a88520e9a8387fa159eb389018f468f79c1eb0408d716e37ba550d37f59aaf2bcb6d393b1d5e1c00488a8a751bec6eb6e6be9ca63d152b676760e7a7a2274821
6
+ metadata.gz: abe9db44c008c686a0cf72a591852b8ffd0136ab13034a40afca9c908ea0a5671d55b7f7898eccf26b0a319c4653e659253606e343c8cf036e1050440e3298a3
7
+ data.tar.gz: 69f966495135331c331599167126f4bc9efb358ed49f75d5c6e872b9eb90370dac9d27ec258f8b0f623fc92a6292610ba9eba145a880fffddb93b8afc1405dda
data/bin/analyze CHANGED
@@ -14,7 +14,7 @@ OptionParser.new do |opts|
14
14
  options[:lib] = v
15
15
  end
16
16
 
17
- opts.on("-n x,y,z", Array, "Example 'list' of arguments") do |list|
17
+ opts.on("-n x,y,z", Array, "A paramater N that will be defined in the test. Each test will run once for each N") do |list|
18
18
  options[:n] = list.map(&:to_i)
19
19
  end
20
20
 
data/lib/analyzer/rss.rb CHANGED
@@ -39,8 +39,8 @@ class Analyzer
39
39
  # Pull memory from `ps` command, takes more resources and can freeze
40
40
  # in low memory situations
41
41
  def ps_memory
42
- KB_TO_BYTE * BigDecimal.new(`ps -o rss= -p #{@pid}`)
42
+ KB_TO_BYTE * BigDecimal(`ps -o rss= -p #{@pid}`)
43
43
  end
44
44
 
45
45
  end
46
- end
46
+ end
@@ -1,3 +1,3 @@
1
1
  class Analyzer
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.5'
3
3
  end
data/lib/analyzer.rb CHANGED
@@ -1,18 +1,26 @@
1
1
  require 'erb'
2
2
  require 'json'
3
3
  require 'tmpdir'
4
+ require 'fileutils'
4
5
 
5
6
  class Analyzer
6
7
 
7
8
  def initialize(*test_files, bootstrap: nil, lib: nil, n: nil)
8
9
  @bootstrap = bootstrap
9
10
  @lib = lib
10
- @n = n
11
+ @n = n || [1]
11
12
  @test_files = test_files
13
+
14
+ @keys = test_files.map { |fn| File.basename(fn, '.*') }
15
+ depth = -1
16
+ while @keys.uniq.length < @keys.length
17
+ @keys = test_files.map { |fn| ( File.dirname(fn).split(File::SEPARATOR)[depth..-1] + [File.basename(fn, '.*')] ).join(File::SEPARATOR) }
18
+ depth -= 1
19
+ end
12
20
  end
13
21
 
14
22
  def key(value)
15
- File.basename(value, ".*")
23
+ @keys[@test_files.index(value)]
16
24
  end
17
25
 
18
26
  def tests
@@ -29,23 +37,28 @@ class Analyzer
29
37
  end
30
38
 
31
39
  def write_results_for(type, dir)
32
- Dir.mkdir(File.join(dir, type))
33
- @test_files.each do |src|
34
- File.open(File.join(dir, type, key(src)), 'w') do |file|
35
- send(:"output_#{type}_results", calculate_results_for(type, File.read(src)), file)
40
+ @n.each do |n|
41
+ @test_files.each do |src|
42
+ if key(src).index(File::SEPARATOR)
43
+ FileUtils.mkdir_p(File.join(dir, type, n.to_s, File.dirname(key(src))))
44
+ else
45
+ FileUtils.mkdir_p(File.join(dir, type, n.to_s))
46
+ end
47
+ File.open(File.join(dir, type, n.to_s, key(src)), 'w') do |file|
48
+ send(:"output_#{type}_results", calculate_results_for(type, File.read(src), n), file)
49
+ end
36
50
  end
37
51
  end
38
52
  end
39
53
 
40
- def calculate_results_for(type, src)
54
+ def calculate_results_for(type, src, n=1)
41
55
  lib = @lib ? File.read(File.expand_path(@lib)) : ''
56
+ setup = "N=#{n}\n"
42
57
 
43
58
  if src.index("\n__SETUP__\n")
44
59
  src = src.split("\n__SETUP__\n")
45
- setup = src[0]
60
+ setup << src[0]
46
61
  src = src[1]
47
- else
48
- setup = ''
49
62
  end
50
63
 
51
64
  analyzer_dir = File.expand_path("../", __FILE__)
@@ -40,7 +40,8 @@ set style boxplot range 2 nooutliers candlesticks
40
40
  set style fill solid 0.2
41
41
  set xtics (<%= tests.map.with_index { |f, i| "'#{escape(f)}' #{i+1}"}.join(', ') %>) scale 0,0
42
42
 
43
- plot <%= tests.map.with_index { |t, i| "'#{File.join(data_dir, 'ips', t)}' using (#{i+1}.0):1 with boxplot linestyle #{i+1}" }.join(', ') %>
43
+ plot \
44
+ <% @n.each_with_index do |n, ni| %><% tests.each_with_index do |t, i| %>'<%= File.join(data_dir, 'ips', n.to_s, t) %>' using (<%= i+1 %>.0):1 title '<%= escape(t) + (@n.size == 1 ? '' : " #{n}" ) %>' with boxplot linestyle <%= i +1 %> dt <%= ni+1 %><%= tests.size == i+1 && @n.last == n ? '' : ", \\\n" %><% end %><% end %>
44
45
 
45
46
 
46
47
  set title "GC Objects Allocated"
@@ -49,22 +50,24 @@ set yrange [0:*]
49
50
  set xrange [0:5]
50
51
  set xtics autofreq
51
52
 
52
-
53
- plot <%= tests.map.with_index { |k, i| "'#{File.join(data_dir, 'gc', k)}' using 2:5 title '#{escape(k)}' with steps linestyle #{i+1}" }.join(', ') %>
53
+ plot \
54
+ <% @n.each_with_index do |n, ni| %><% tests.each_with_index do |t, i| %>'<%= File.join(data_dir, 'gc', n.to_s, t) %>' using 2:5 title '<%= escape(t) + (@n.size == 1 ? '' : " #{n}" ) %>' with steps linestyle <%= i +1 %> dt <%= ni+1 %><%= tests.size == i+1 && @n.last == n ? '' : ", \\\n" %><% end %><% end %>
54
55
 
55
56
  set title "GC Objects Freed"
56
57
  set key on
57
58
  set yrange [0:*]
58
59
  set xrange [0:5]
59
60
 
60
- plot <%= tests.map.with_index { |k, i| "'#{File.join(data_dir, 'gc', k)}' using 2:6 title '#{escape(k)}' with steps linestyle #{i+1}" }.join(', ') %>
61
+ plot \
62
+ <% @n.each_with_index do |n, ni| %><% tests.each_with_index do |t, i| %>'<%= File.join(data_dir, 'gc', n.to_s, t) %>' using 2:6 title '<%= escape(t) + (@n.size == 1 ? '' : " #{n}" ) %>' with steps linestyle <%= i +1 %> dt <%= ni+1 %><%= tests.size == i+1 && @n.last == n ? '' : ", \\\n" %><% end %><% end %>
61
63
 
62
64
  set title "GC Retained"
63
65
  set key on
64
66
  set yrange [0:*]
65
67
  set xrange [0:5]
66
68
 
67
- plot <%= tests.map.with_index { |k, i| "'#{File.join(data_dir, 'gc', k)}' using 2:(\\$3-\\$4) title '#{escape(k)}' with steps linestyle #{i+1}" }.join(', ') %>
69
+ plot \
70
+ <% @n.each_with_index do |n, ni| %><% tests.each_with_index do |t, i| %>'<%= File.join(data_dir, 'gc', n.to_s, t) %>' using 2:(\$3-\$4) title '<%= escape(t) + (@n.size == 1 ? '' : " #{n}" ) %>' with steps linestyle <%= i +1 %> dt <%= ni+1 %><%= tests.size == i+1 && @n.last == n ? '' : ", \\\n" %><% end %><% end %>
68
71
 
69
72
  # , \\$alloc#{k} using 1:8 with impulses linestyle 7 title 'minor' axes x1y2, \\$alloc#{k} using 1:9 with impulses linestyle 8 title 'major' axes x1y2
70
73
 
@@ -73,4 +76,5 @@ set key on
73
76
  set yrange [0:*]
74
77
  set xrange [0:5]
75
78
 
76
- plot <%= tests.map.with_index { |k, i| "'#{File.join(data_dir, 'rss', k)}' using 2:3 title '#{escape(k)}' with steps linestyle #{i+1}" }.join(', ') %>
79
+ plot \
80
+ <% @n.each_with_index do |n, ni| %><% tests.each_with_index do |t, i| %>'<%= File.join(data_dir, 'rss', n.to_s, t) %>' using 2:3 title '<%= escape(t) + (@n.size == 1 ? '' : " #{n}" ) %>' with steps linestyle <%= i +1 %> dt <%= ni+1 %><%= tests.size == i+1 && @n.last == n ? '' : ", \\\n" %><% end %><% end %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-13 00:00:00.000000000 Z
11
+ date: 2021-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.7'
27
- description:
27
+ description:
28
28
  email:
29
29
  - jonbracy@gmail.com
30
30
  executables:
@@ -49,7 +49,7 @@ licenses:
49
49
  - MIT
50
50
  metadata:
51
51
  source_code_uri: https://github.com/malomalo/analyzer
52
- post_install_message:
52
+ post_install_message:
53
53
  rdoc_options: []
54
54
  require_paths:
55
55
  - lib
@@ -65,9 +65,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  version: '0'
66
66
  requirements:
67
67
  - gnuplot
68
- rubyforge_project:
69
- rubygems_version: 2.6.11
70
- signing_key:
68
+ rubygems_version: 3.2.22
69
+ signing_key:
71
70
  specification_version: 4
72
71
  summary: A Performance analyzer for Ruby
73
72
  test_files: []