Skip to content

Instantly share code, notes, and snippets.

@bbrowning
Created December 8, 2014 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbrowning/e2a70c3dfac2faf6b75d to your computer and use it in GitHub Desktop.
Save bbrowning/e2a70c3dfac2faf6b75d to your computer and use it in GitHub Desktop.
require 'benchmark'
NUM_THREADS = 60
NUM_OPENS = 40_000
TEMP_FILE = '/tmp/umask_contention'
File.open(TEMP_FILE, 'w') do |f|
f.write("umask contention, man\n" * 100)
end
puts Benchmark.measure {
threads = NUM_THREADS.times.map do
Thread.new do
NUM_OPENS.times do
file = File.open(TEMP_FILE)
file.read(5)
file.close
end
end
end
threads.each(&:join)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment