Created
October 20, 2008 06:52
-
-
Save mattly/18030 to your computer and use it in GitHub Desktop.
profile of max<>ruby vs pure ruby scheduling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'datagrammer' | |
require 'statarray' | |
deltas = StatArray.new | |
ticks = StatArray.new | |
d = Datagrammer.new(5000) | |
last = Time.now.to_f | |
last_tick = 0 | |
d.listen do |slf, msg| | |
now = Time.now.to_f | |
ticks << msg.last - last_tick | |
deltas << (now - last) * 1000 | |
last = now | |
last_tick = msg.last | |
end | |
puts "running from Max>UDP ticks for thirty seconds..." | |
sleep 30 | |
puts "done! calculating..." | |
# removes bad first values | |
deltas.shift | |
ticks.shift | |
puts "deltas:" | |
deltas.to_stats.each_pair {|k,v| puts "#{k}: #{v}"} | |
puts "-----\nticks:" | |
ticks.to_stats.each_pair {|k,v| puts "#{k}: #{v}"} | |
puts "running with -sleep- for thirty seconds" | |
sleeping = StatArray.new | |
last = Time.now.to_f | |
Thread.start do | |
loop do | |
now = Time.now.to_f | |
sleeping << (now - last) * 1000 | |
last = now | |
sleep 0.00520833 | |
end | |
end | |
sleep 30 | |
puts "done! calculating..." | |
sleeping.shift | |
puts "deltas:" | |
sleeping.to_stats.each_pair {|k,v| puts "#{k}: #{v}"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment