Skip to content

Instantly share code, notes, and snippets.

@ChuckO
Created June 28, 2012 22:28
Show Gist options
  • Select an option

  • Save ChuckO/3014392 to your computer and use it in GitHub Desktop.

Select an option

Save ChuckO/3014392 to your computer and use it in GitHub Desktop.
Take a BM
r1.9.3 ~/workarea/take_a_bm $ ruby take_a_bm.rb
Thread.current.object_id:70331712734240 0.000000 0.000000 0.000000 ( 1.001500)
Thread.current.object_id:70331712733480 0.000000 0.000000 0.000000 ( 1.001537)
Thread.current.object_id:70331712733240 0.000000 0.000000 0.000000 ( 1.001746)
Thread.current.object_id:70331712732600 0.000000 0.000000 0.000000 ( 1.001865)
Thread.current.object_id:70331712731560 0.000000 0.000000 0.000000 ( 1.002109)
Thread.current.object_id:70331712733660 0.000000 0.000000 0.000000 ( 1.000823)
Thread.current.object_id:70331712733400 0.000000 0.000000 0.000000 ( 1.002661)
Thread.current.object_id:70331712733000 0.000000 0.000000 0.000000 ( 1.002736)
Thread.current.object_id:70331712729480 0.000000 0.000000 0.000000 ( 1.002143)
Thread.current.object_id:70331712728980 0.000000 0.000000 0.000000 ( 1.002188)
Thread.current.object_id:70331712728880 0.000000 0.000000 0.000000 ( 1.002407)
Thread.current.object_id:70331712727960 0.000000 0.000000 0.000000 ( 1.002431)
Thread.current.object_id:70331712732840 0.000000 0.000000 0.000000 ( 1.003648)
Thread.current.object_id:70331712732200 0.000000 0.000000 0.000000 ( 1.002072)
Thread.current.object_id:70331712731160 0.000000 0.000000 0.000000 ( 1.003479)
Thread.current.object_id:70331712729720 0.000000 0.000000 0.000000 ( 1.003322)
Thread.current.object_id:70331712728800 0.000000 0.010000 0.010000 ( 1.003237)
Thread.current.object_id:70331712727320 0.000000 0.010000 0.010000 ( 1.003097)
Thread.current.object_id:70331712729400 0.000000 0.010000 0.010000 ( 1.003734)
Thread.current.object_id:70331712732520 0.000000 0.010000 0.010000 ( 1.004570)
Thread.current.object_id:70331712728560 0.000000 0.010000 0.010000 ( 1.003859)
Thread.current.object_id:70331721364060 0.000000 0.010000 0.010000 ( 2.001248)
Thread.current.object_id:70331721292420 0.000000 0.010000 0.010000 ( 2.001208)
Thread.current.object_id:70331712731480 0.000000 0.010000 0.010000 ( 2.000716)
Thread.current.object_id:70331712743460 0.000000 0.010000 0.010000 ( 2.001051)
Thread.current.object_id:70331712733840 0.000000 0.010000 0.010000 ( 2.001384)
Thread.current.object_id:70331712732440 0.000000 0.010000 0.010000 ( 2.001261)
Thread.current.object_id:70331712730060 0.000000 0.010000 0.010000 ( 2.000953)
Thread.current.object_id:70331712729880 0.000000 0.010000 0.010000 ( 2.000976)
Thread.current.object_id:70331712729980 0.000000 0.010000 0.010000 ( 2.001152)
Thread.current.object_id:70331712728720 0.000000 0.010000 0.010000 ( 2.000938)
Thread.current.object_id:70331712727240 0.000000 0.010000 0.010000 ( 2.000733)
Thread.current.object_id:70331712729560 0.000000 0.010000 0.010000 ( 2.001325)
Thread.current.object_id:70331712732360 0.000000 0.010000 0.010000 ( 2.002013)
Thread.current.object_id:70331712728640 0.000000 0.010000 0.010000 ( 2.001267)
Thread.current.object_id:70331712727480 0.000000 0.010000 0.010000 ( 2.001116)
Thread.current.object_id:70331712729300 0.000000 0.010000 0.010000 ( 2.001593)
Thread.current.object_id:70331721325460 0.000000 0.010000 0.010000 ( 2.002926)
Thread.current.object_id:70331721364300 0.000000 0.010000 0.010000 ( 3.000109)
Thread.current.object_id:70331712730660 0.000000 0.010000 0.010000 ( 3.000207)
Thread.current.object_id:70331712734000 0.000000 0.010000 0.010000 ( 3.001006)
Thread.current.object_id:70331712733920 0.010000 0.010000 0.020000 ( 3.001121)
Thread.current.object_id:70331712732120 0.010000 0.010000 0.020000 ( 3.000868)
Thread.current.object_id:70331712731720 0.010000 0.010000 0.020000 ( 3.000873)
Thread.current.object_id:70331712731320 0.010000 0.010000 0.020000 ( 3.000886)
Thread.current.object_id:70331712731000 0.010000 0.010000 0.020000 ( 3.000907)
Thread.current.object_id:70331712730420 0.010000 0.010000 0.020000 ( 3.000882)
Thread.current.object_id:70331712730580 0.010000 0.010000 0.020000 ( 3.001006)
Thread.current.object_id:70331721364140 0.010000 0.010000 0.020000 ( 3.002114)
Thread.current.object_id:70331721367100 0.000000 0.010000 0.010000 ( 3.000893)
Thread.current.object_id:70331712733760 0.010000 0.010000 0.020000 ( 3.001858)
Thread.current.object_id:70331712733080 0.010000 0.010000 0.020000 ( 3.001819)
Thread.current.object_id:70331712730900 0.010000 0.010000 0.020000 ( 3.001471)
Thread.current.object_id:70331712730820 0.010000 0.010000 0.020000 ( 3.001566)
Thread.current.object_id:70331712730240 0.010000 0.010000 0.020000 ( 3.001549)
Thread.current.object_id:70331712729220 0.010000 0.010000 0.020000 ( 3.001350)
Thread.current.object_id:70331712728480 0.010000 0.010000 0.020000 ( 3.001272)
Thread.current.object_id:70331712728140 0.010000 0.010000 0.020000 ( 3.001296)
Thread.current.object_id:70331712727880 0.010000 0.010000 0.020000 ( 3.001323)
Thread.current.object_id:70331712731880 0.010000 0.010000 0.020000 ( 3.002304)
Thread.current.object_id:70331712731400 0.010000 0.010000 0.020000 ( 3.002323)
Thread.current.object_id:70331712729800 0.010000 0.010000 0.020000 ( 3.002082)
Thread.current.object_id:70331712728220 0.010000 0.010000 0.020000 ( 3.001850)
Thread.current.object_id:70331712727640 0.010000 0.010000 0.020000 ( 3.001837)
Thread.current.object_id:70331712730340 0.010000 0.010000 0.020000 ( 3.002557)
Thread.current.object_id:70331712729140 0.010000 0.010000 0.020000 ( 3.002318)
Thread.current.object_id:70331712734080 0.010000 0.010000 0.020000 ( 3.003562)
Thread.current.object_id:70331712728400 0.010000 0.010000 0.020000 ( 3.002420)
Thread.current.object_id:70331721291740 0.010000 0.010000 0.020000 ( 4.000321)
Thread.current.object_id:70331712734320 0.010000 0.010000 0.020000 ( 4.000466)
Thread.current.object_id:70331712734160 0.010000 0.010000 0.020000 ( 4.000517)
Thread.current.object_id:70331712727160 0.010000 0.010000 0.020000 ( 4.001049)
Thread.current.object_id:70331712732760 0.010000 0.010000 0.020000 ( 4.000992)
Thread.current.object_id:70331712731640 0.010000 0.010000 0.020000 ( 4.000998)
Thread.current.object_id:70331712731240 0.010000 0.010000 0.020000 ( 4.001015)
Thread.current.object_id:70331712729640 0.010000 0.010000 0.020000 ( 4.000750)
Thread.current.object_id:70331712732040 0.010000 0.010000 0.020000 ( 4.001340)
Thread.current.object_id:70331712731960 0.010000 0.010000 0.020000 ( 4.000949)
Thread.current.object_id:70331712730160 0.010000 0.010000 0.020000 ( 4.001085)
Thread.current.object_id:70331712730500 0.010000 0.010000 0.020000 ( 4.001323)
Thread.current.object_id:70331712728040 0.010000 0.010000 0.020000 ( 4.000996)
Thread.current.object_id:70331712727400 0.010000 0.010000 0.020000 ( 4.000977)
Thread.current.object_id:70331721364380 0.010000 0.010000 0.020000 ( 4.001028)
Thread.current.object_id:70331712727560 0.010000 0.010000 0.020000 ( 4.001222)
Thread.current.object_id:70331712728300 0.010000 0.010000 0.020000 ( 4.001464)
Thread.current.object_id:70331721370260 0.010000 0.010000 0.020000 ( 5.001081)
Thread.current.object_id:70331712733160 0.010000 0.010000 0.020000 ( 5.001176)
Thread.current.object_id:70331712732680 0.010000 0.010000 0.020000 ( 5.001361)
Thread.current.object_id:70331712732920 0.010000 0.010000 0.020000 ( 5.001677)
Thread.current.object_id:70331712732280 0.010000 0.010000 0.020000 ( 5.001693)
Thread.current.object_id:70331712731080 0.010000 0.010000 0.020000 ( 5.001658)
Thread.current.object_id:70331712730740 0.010000 0.010000 0.020000 ( 5.001752)
Thread.current.object_id:70331712729060 0.010000 0.010000 0.020000 ( 5.001533)
Thread.current.object_id:70331712733580 0.010000 0.010000 0.020000 ( 5.002648)
Thread.current.object_id:70331721364220 0.010000 0.010000 0.020000 ( 5.003304)
Thread.current.object_id:70331712751800 0.010000 0.010000 0.020000 ( 5.000782)
Thread.current.object_id:70331712727720 0.010000 0.010000 0.020000 ( 5.001888)
Thread.current.object_id:70331712731800 0.010000 0.010000 0.020000 ( 5.002925)
Thread.current.object_id:70331712733320 0.010000 0.010000 0.020000 ( 5.003553)
Thread.current.object_id:70331712727800 0.010000 0.010000 0.020000 ( 5.002197)
require "benchmark"
def my_bm sleepy_time
bm = Benchmark.measure do
sleep sleepy_time
end
puts "Thread.current.object_id:#{Thread.current.object_id} #{bm}"
end
n_threads = 100
threads = []
1.upto( n_threads ) do |n|
threads << Thread.new{ my_bm rand(5)+1 }
end
threads.each{ |t| t.join }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment