Skip to content

Commit

Permalink
Workings Set
Browse files Browse the repository at this point in the history
  • Loading branch information
jschementi committed Feb 5, 2009
1 parent 8da8fd7 commit a3b2ac4
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
12 changes: 5 additions & 7 deletions app.rb
Expand Up @@ -2,15 +2,10 @@
require 'sinatra'

require 'mymath'
require 'dbg'

require 'activesupport'

def dbg
require 'ruby-debug'
Debugger.start
debugger
end

helpers do
def time(t)
t = t.to_f
Expand Down Expand Up @@ -73,7 +68,7 @@ def total_binary_size(binaries)
end

def mb(bytes)
bytes./(1_000_000.0).round_to(2)
bytes./(1024*1024.0).round_to(2)
end
end

Expand Down Expand Up @@ -157,6 +152,9 @@ def mb(bytes)
%tr
%th Binary size
%td{:colspan => 4}= size(total_binary_size(stats[:binsize]))
%tr
%th Working set
%td{:colspan => 4}= size stats[:working_set]
%tr
%th Github repository size
%td{:colspan => 4}= size stats[:repo]
Expand Down
6 changes: 6 additions & 0 deletions dbg.rb
@@ -0,0 +1,6 @@
def dbg
require 'ruby-debug'
Debugger.start
debugger
end

3 changes: 3 additions & 0 deletions getpid.rb
@@ -0,0 +1,3 @@
File.open('data/pid', 'w'){ |f| f.print Process.pid }
a = 0
a += 1 while true
1 change: 1 addition & 0 deletions retry.rb
@@ -1,6 +1,7 @@
require 'win32ole'
require 'rubygems'
require 'win32/process'
require 'dbg'

puts "Cleaning ..."
system 'ruby stats.rb --clean'
Expand Down
42 changes: 34 additions & 8 deletions stats.rb
Expand Up @@ -12,18 +12,13 @@
require 'fileutils'
require 'mymath'
require 'benchmark'

require 'win32ole'
require 'net/http'
require 'uri'

require 'rubygems'
require 'net/scp'

def dbg
require 'ruby-debug'
Debugger.start
debugger
end
require 'dbg'

#
# Helpers
Expand Down Expand Up @@ -85,6 +80,29 @@ def size_of_binaries
inject({}){ |s, f| s[f] = File.size(f); s }
end

def working_set
working_set = 0
begin
t = Thread.new{ system "#{IR} #{CD}/getpid.rb" }
puts "Letting IronRuby run for 5 seconds..."
sleep(5)
puts "Getting working set"
pid = File.open("#{DATA}/pid", 'r'){|f| f.read }
processes = WIN32OLE.connect("winmgmts://").ExecQuery(
"select * from win32_process where ProcessId = #{pid}")
if processes.count == 1
processes.each{|p| working_set = p.WorkingSetSize}
else
puts "*Error: found more than one process with pid==#{pid}"
end
Thread.kill(t)
Process.kill(9, pid)
rescue
FileUtils.rm "#{DATA}/pid" if File.exist? "#{DATA}/pid"
end
working_set.to_i
end

def github_size
get_ironruby_from_github[:size]
end
Expand Down Expand Up @@ -248,6 +266,10 @@ def report_throughput
throughput
end

def report_working_set
working_set
end

def report_mspec_language
_mspec(:language)
end
Expand Down Expand Up @@ -335,6 +357,10 @@ def report_throughput
"Throughput: (100000 iterations): #{data.map{|k,v| "#{k}(#{v} s)"}.join(", ")}\n"
end

def report_working_set
"Working set: #{mb data} MB\n"
end

def report_mspec_language
_mspec
end
Expand Down Expand Up @@ -362,7 +388,7 @@ def total_binary_size(binaries)
end

def mb(bytes)
bytes./(1_000_000.0).round_to(2)
bytes./(1024*1024.0).round_to(2)
end
end

Expand Down

0 comments on commit a3b2ac4

Please sign in to comment.