summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-08 21:53:48 (GMT)
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-08 21:53:48 (GMT)
commit68c35d8bb94d2b714ef7e7f9426c4b22b1cf01a9 (patch)
tree0a000e60eeafa74b66d430be61a3e1131705c85a /benchmark
parentae858695062c509650b9d3797201ddbd5e57f4bf (diff)
* 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
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/prepare_require.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/benchmark/prepare_require.rb b/benchmark/prepare_require.rb
index 40926df..c4786f0 100644
--- a/benchmark/prepare_require.rb
+++ b/benchmark/prepare_require.rb
@@ -1,14 +1,25 @@
require "fileutils"
-basename = File.dirname($0)
-data_dir = File.join(basename, "bm_require.data")
+def prepare
+ num_files = 10000
-FileUtils.mkdir_p(data_dir)
+ basename = File.dirname($0)
+ data_dir = File.join(basename, "bm_require.data")
-1.upto(10000) do |i|
- f = File.open("#{data_dir}/c#{i}.rb", "w")
- f.puts <<-END
+ # 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