Plot time offsets on X axes when profiling.
This commit is contained in:
parent
f4a71d7f63
commit
3344f373bd
|
@ -2,20 +2,15 @@
|
||||||
|
|
||||||
set title sample_file
|
set title sample_file
|
||||||
|
|
||||||
set xlabel "Time"
|
set xlabel "Runtime (seconds)"
|
||||||
set ylabel "Memory (MB)"
|
set ylabel "Memory (MB)"
|
||||||
|
|
||||||
set xdata time
|
set xtics 1
|
||||||
set timefmt "%Y-%m-%dT%H:%M:%S"
|
|
||||||
|
|
||||||
set yrange [0:*]
|
|
||||||
|
|
||||||
set term wx persist size 900,600
|
set term wx persist size 900,600
|
||||||
set grid
|
set grid
|
||||||
|
|
||||||
set style line 1 lc rgb "#0060ad" lt 1 lw 2 pt 7 ps 1
|
set style line 1 lc rgb "#0060ad" lt 1 lw 2 pt 7 ps 1
|
||||||
|
set style data linespoints
|
||||||
|
|
||||||
plot sample_file \
|
plot sample_file using 1:($2 / 1024 ** 2) ls 1 title "Memory"
|
||||||
using 1:($2 / 1024 ** 2) \
|
|
||||||
with linespoints ls 1 \
|
|
||||||
title "Memory"
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
require 'timeout'
|
require 'timeout'
|
||||||
require 'time'
|
|
||||||
|
|
||||||
require_relative '../lib/oga'
|
require_relative '../lib/oga'
|
||||||
|
|
||||||
|
@ -41,15 +40,16 @@ def profile_memory(name, duration = 30)
|
||||||
path = File.expand_path("../samples/#{name}.txt", __FILE__)
|
path = File.expand_path("../samples/#{name}.txt", __FILE__)
|
||||||
handle = File.open(path, 'w')
|
handle = File.open(path, 'w')
|
||||||
handle.sync = true
|
handle.sync = true
|
||||||
|
start_time = Time.now
|
||||||
|
|
||||||
while monitor
|
while monitor
|
||||||
usage = memory_usage
|
usage = memory_usage
|
||||||
usage_mb = (usage / 1024 / 1024).round(2)
|
usage_mb = (usage / 1024 / 1024).round(2)
|
||||||
time = Time.now.strftime('%Y-%m-%dT%H:%M:%S')
|
runtime = Time.now - start_time
|
||||||
|
|
||||||
handle.write("#{time} #{usage}\n")
|
handle.write("#{runtime} #{usage}\n")
|
||||||
|
|
||||||
puts "#{time}: #{usage_mb} MB"
|
puts "#{usage_mb} MB"
|
||||||
|
|
||||||
sleep(rand)
|
sleep(rand)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue