Created
May 12, 2011 17:47
-
-
Save icem/969050 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
# Script for testing disk drive | |
# Usage: ruby random_stream_test.rb filepath [ size ] | |
FILENAME = ARGV.first | |
n = ARGV.last.to_i || 1000 | |
puts "Start writing #{n} lines to file '#{FILENAME}'..." | |
File.open(FILENAME, "w") do |file| | |
n.times do | |
str = '' | |
100000.times { str << 97 + rand(26) } #Generation long random string | |
file.puts str | |
file.puts str.hash | |
end | |
end | |
puts "Start reading with veryfying..." | |
File.open(FILENAME, "r") do |file| | |
counter = 0 | |
hash = nil | |
while (line = file.gets) | |
counter+=1 | |
if (counter.even?) | |
print(hash == line.to_i ? "+" : "-") | |
else | |
hash = line.strip.hash | |
end | |
end | |
puts "\nSize ok" if counter == 2*n | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment