Created
November 19, 2009 23:23
-
-
Save metaskills/239141 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 '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) |
This file contains hidden or 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
# 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