lib/perfmonger/command/plot.rb in perfmonger-0.10.2 vs lib/perfmonger/command/plot.rb in perfmonger-0.11.0
- old
+ new
@@ -22,10 +22,11 @@
@offset_time = 0.0
@output_dir = Dir.pwd
@output_type = 'pdf'
@output_prefix = ''
@save_gpfiles = false
+ @disk_only = nil
@disk_only_regex = nil
@disk_plot_read = true
@disk_plot_write = true
@disk_numkey_threshold = 10
@plot_iops_max = nil
@@ -76,10 +77,11 @@
'Save GNUPLOT and data files.') do
@save_gpfiles = true
end
@parser.on('--disk-only REGEX', "Select disk devices that matches REGEX") do |regex|
+ @disk_only = regex
@disk_only_regex = Regexp.compile(regex)
end
@parser.on('--plot-read-only', "Plot only READ performance for disks") do
@disk_plot_read = true
@@ -137,11 +139,17 @@
@disk_dat = File.expand_path("disk.dat", @tmpdir)
@cpu_dat = File.expand_path("cpu.dat", @tmpdir)
meta_json = nil
- IO.popen([formatter_bin, "-perfmonger", @data_file, "-cpufile", @cpu_dat, "-diskfile", @disk_dat], "r") do |io|
+ cmd = [formatter_bin, "-perfmonger", @data_file, "-cpufile", @cpu_dat,
+ "-diskfile", @disk_dat]
+ if @disk_only_regex
+ cmd << "-disk-only"
+ cmd << @disk_only
+ end
+ IO.popen(cmd, "r") do |io|
meta_json = io.read
end
if $?.exitstatus != 0
puts("ERROR: failed to run perfmonger-plot-formatter")
exit(false)
@@ -149,12 +157,10 @@
meta = JSON.parse(meta_json)
plot_disk(meta)
plot_cpu(meta)
- FileUtils.rm_rf(@tmpdir)
-
true
end
private
def plot_disk(meta)
@@ -389,14 +395,14 @@
nr_cpu_factors = factors(nr_cpu)
nr_cols = nr_cpu_factors.select do |x|
x <= Math.sqrt(nr_cpu)
end.max
- nr_cols ||= Math.sqrt(nr_cpu).ceil
+ nr_cols = 1
nr_rows = nr_cpu / nr_cols
- plot_height = 8
+ plot_height = ([nr_cpu, 8].min) + ([nr_cpu - 8, 0].max) * 0.5
if nr_rows == 1
plot_height /= 2.0
end
@@ -422,17 +428,17 @@
plot_stmt = "\"cpu.dat\" ind #{cpu_idx+1} usi 1:(#{stack_columns.map{|i| "$#{i}"}.join("+")}) with filledcurve x1 lw 0 lc #{idx+1} title \"#{key}\""
plot_stmt_list << plot_stmt
end
all_gpfile.puts <<EOS
-set title 'cpu #{cpu_idx}' offset 0.0,-0.7 font 'Arial,16'
+set title 'cpu #{cpu_idx}' offset -61,-3 font 'Arial,16'
unset key
set origin #{xpos}, #{ypos}
set size #{1.0/nr_cols}, #{(1.0 - legend_height)/nr_rows}
-set rmargin 0.5
-set lmargin 3.5
-set tmargin 1.3
-set bmargin 1.3
+set rmargin 2
+set lmargin 12
+set tmargin 0.5
+set bmargin 0.5
set xtics offset 0.0,0.5
set ytics offset 0.5,0
set style fill noborder
plot #{plot_stmt_list.reverse.join(",\\\n ")}