Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixed file io bm

  • Loading branch information...
commit 0ab68f09e58ced1bbcda431c96b997dbccd8f1f0 1 parent e1d5be3
coderrr authored
9 benchmarks/green_vs_native/file_io_write.rb
@@ -13,6 +13,7 @@ def just_yield
13 13 OpenStruct.new
14 14 end
15 15
  16 +one_meg = "a" * 1024 * 1024
16 17 BM = lambda do
17 18 puts "writing to #{n} files concurrently"
18 19 run = lambda do
@@ -20,9 +21,13 @@ def just_yield
20 21 Benchmark.realtime do
21 22 threads = []
22 23 n.times do
23   - threads << Thread.new do
  24 + threads << switch do
24 25 File.open("TMP_io_write_#{Thread.current.object_id.abs}", "wb") do |f|
25   - f.puts "a" * 1024 * 1024
  26 + 1024.times do
  27 + f.puts rand
  28 + f.flush
  29 + end
  30 +# f.puts one_meg
26 31 end
27 32 end
28 33 end
5 benchmarks/green_vs_native/switching_forced.rb
@@ -11,10 +11,9 @@ def x; end
11 11 baseline = Benchmark.realtime do
12 12 threads = []
13 13 100.times do
14   - threads << t = Thread.new do
  14 + threads << Thread.new do
15 15 n.times { x }
16   - end
17   - t.join
  16 + end.join
18 17 end
19 18 end
20 19
4 bm_runner_jruby.rb
... ... @@ -1,6 +1,8 @@
  1 +load File.expand_path('~/.ruby_bm_config')
  2 +
1 3 load ARGV.shift
2 4
3   -repeat = 1
  5 +repeat = $jruby_test_repeats
4 6
5 7 baselines = times = 0
6 8
1  dot_ruby_bm_config.example
... ... @@ -1 +1,2 @@
1 1 $ruby_19_dir = '/home/me/rubysrc/ruby-1.9.1-rc1'
  2 +$jruby_test_repeats = 4

0 comments on commit 0ab68f0

Please sign in to comment.
Something went wrong with that request. Please try again.