prelude: |
  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|
      File.write("#{data_dir}/c#{i}.rb", "class C#{i}\n""end\n")
    end
  end

  prepare
benchmark:
  require: |
    $:.push File.join(File.dirname(__FILE__), "bm_require.data")

    1.upto(10000) do |i|
      require "c#{i}"
    end

    $:.pop
loop_count: 1
