xref: /Universal-ctags/Units/parser-rake.r/anonymous.d/input.rake (revision 2e8e12f818fe2fd6c3ae0a1c8ffc92b52b2ae5b7)
1# Based on from puppet/tasks/benchmark.rake
2namespace :benchmark do
3  def generate_scenario_tasks(location, name)
4    desc File.read(File.join(location, 'description'))
5    task name => "#{name}:run"
6    # Load a BenchmarkerTask to handle config of the benchmark
7    task_handler_file = File.expand_path(File.join(location, 'benchmarker_task.rb'))
8    if File.exist?(task_handler_file)
9      require task_handler_file
10      run_args = BenchmarkerTask.run_args
11    else
12      run_args = []
13    end
14
15    namespace name do
16      task :setup do
17        ENV['ITERATIONS'] ||= '10'
18        ENV['SIZE'] ||= '100'
19        ENV['TARGET'] ||= Dir.mktmpdir(name)
20        ENV['TARGET'] = File.expand_path(ENV['TARGET'])
21
22        mkdir_p(ENV['TARGET'])
23
24        require File.expand_path(File.join(location, 'benchmarker.rb'))
25
26        @benchmark = Benchmarker.new(ENV['TARGET'], ENV['SIZE'].to_i)
27      end
28
29      task :generate => :setup do
30        @benchmark.generate
31        @benchmark.setup
32      end
33    end
34  end
35end
36