ruby-changes:40005
From: kosaki <ko1@a...>
Date: Fri, 9 Oct 2015 06:53:56 +0900 (JST)
Subject: [ruby-changes:40005] kosaki:r52086 (trunk): * benchmark/prepare_require.rb: skip file creation if it already
kosaki 2015-10-09 06:53:48 +0900 (Fri, 09 Oct 2015) New Revision: 52086 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52086 Log: * benchmark/prepare_require.rb: skip file creation if it already exist. Suggested by ko1. Modified files: trunk/ChangeLog trunk/benchmark/prepare_require.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 52085) +++ ChangeLog (revision 52086) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Oct 9 06:52:49 2015 KOSAKI Motohiro <kosaki.motohiro@g...> + + * benchmark/prepare_require.rb: skip file creation if it already + exist. Suggested by ko1. + Fri Oct 9 06:18:04 2015 KOSAKI Motohiro <kosaki.motohiro@g...> * benchmark/bm_require.rb: new benchmark for require. * benchmark/bm_require_thread.rb: new benchmark for conflicting Index: benchmark/prepare_require.rb =================================================================== --- benchmark/prepare_require.rb (revision 52085) +++ benchmark/prepare_require.rb (revision 52086) @@ -1,14 +1,25 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/prepare_require.rb#L1 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/