Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created November 19, 2009 23:23
Show Gist options
  • Save metaskills/239141 to your computer and use it in GitHub Desktop.
Save metaskills/239141 to your computer and use it in GitHub Desktop.
require 'fileutils'
source_path = "/Users/kencollins/Desktop/source.txt"
move_path = "/Users/kencollins/Desktop/move.txt"
FileUtils.rm move_path if File.exists?(move_path)
File.open(source_path,'w') { |f| 30000.times{f.write("#{'x'*70}\n")} }
FileUtils.move source_path, move_path
while File.size?(move_path) == nil do
sleep 0.25
puts "loop"
end
puts IO.read(move_path)
# With and without sleep has same output.
$ /opt/local/bin/ruby1.9 fu_test.rb | wc
30000 30000 2130000
# Now with 300_000 and toggle sleep.
$ /opt/local/bin/ruby1.9 fu_test.rb | wc
300000 300000 21300000
$ /opt/local/bin/ruby1.9 fu_test.rb | wc
300000 300000 21300000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment