summaryrefslogtreecommitdiff
path: root/benchmark/prepare_require.rb
blob: c4786f04ad31bde76153c122c1a7c9c3eecc5ba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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