Plot time offsets on X axes when profiling.

This commit is contained in:
Yorick Peterse 2014-05-01 21:26:05 +02:00
parent f4a71d7f63
commit 3344f373bd
2 changed files with 8 additions and 13 deletions

View File

@ -2,20 +2,15 @@
set title sample_file
set xlabel "Time"
set xlabel "Runtime (seconds)"
set ylabel "Memory (MB)"
set xdata time
set timefmt "%Y-%m-%dT%H:%M:%S"
set yrange [0:*]
set xtics 1
set term wx persist size 900,600
set grid
set style line 1 lc rgb "#0060ad" lt 1 lw 2 pt 7 ps 1
set style data linespoints
plot sample_file \
using 1:($2 / 1024 ** 2) \
with linespoints ls 1 \
title "Memory"
plot sample_file using 1:($2 / 1024 ** 2) ls 1 title "Memory"

View File

@ -1,5 +1,4 @@
require 'timeout'
require 'time'
require_relative '../lib/oga'
@ -41,15 +40,16 @@ def profile_memory(name, duration = 30)
path = File.expand_path("../samples/#{name}.txt", __FILE__)
handle = File.open(path, 'w')
handle.sync = true
start_time = Time.now
while monitor
usage = memory_usage
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)
end