Created
March 23, 2010 00:22
-
-
Save jonforums/340719 to your computer and use it in GitHub Desktop.
Benchmark big write
This file contains 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
# redmine.ruby-lang.org issue #2742 | |
require 'benchmark' | |
begin | |
require 'rbconfig' | |
puts "(#{RbConfig::CONFIG['host_os']}) #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} \ | |
#{RbConfig::CONFIG['CC']} #{RbConfig::CONFIG['optflags']} #{RbConfig::CONFIG['debugflags']}" | |
rescue LoadError | |
end | |
CHR_COUNT, LINE_DELIM = if ARGV[0] && ARGV[0] == 'lf' | |
[ 79, "\n" ] | |
else | |
[ 78, "\r\n" ] | |
end | |
Benchmark.bm(9) do |x| | |
x.report("big_write") do | |
File.open("big_foo.txt", 'wb') do |f| | |
625_000.times { f.write('-' * CHR_COUNT << LINE_DELIM) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment