1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/benchmark/prepare_require.rb
kosaki 68c35d8bb9 * benchmark/prepare_require.rb: skip file creation if it already
exist. Suggested by ko1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-08 21:53:48 +00:00

25 lines
423 B
Ruby

require "fileutils"
def prepare
num_files = 10000
basename = File.dirname($0)
data_dir = File.join(basename, "bm_require.data")
# skip if all of files exists
if File.exist?(File.join(data_dir, "c#{num_files}.rb"))
return
end
FileUtils.mkdir_p(data_dir)
1.upto(num_files) do |i|
f = File.open("#{data_dir}/c#{i}.rb", "w")
f.puts <<-END
class C#{i}
end
END
end
end
prepare