bin/mach5 in mach5-tools-0.0.1 vs bin/mach5 in mach5-tools-0.1.0
- old
+ new
@@ -1,27 +1,29 @@
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'mach5-tools'
+require 'thor'
-def db(json)
- output = {}
- json.each do |commit, benchmarks|
- benchmarks.each do |benchmark, results|
- output[benchmark] ||= {}
- output[benchmark][commit] = results
+class App < Thor
+ desc "benchmark", "Run benchmarks"
+ method_option :all, :type => :boolean, :aliases => "-a", :desc => "Run all benchmarks even if there is already a result"
+ method_option :list, :type => :boolean, :aliases => "-l", :desc => "List all available benchmarks"
+ method_option :only, :type => :array, :aliases => "-o", :desc => "Run only the specified benchmarks"
+ def benchmark
+ runner = Mach5::Runner.new(eval(File.open("Mach5file").readlines.join))
+ if options.list
+ runner.list_benchmarks.each do |benchmark|
+ puts benchmark
+ end
+ elsif options.only
+ runner.benchmark(only: options.only)
+ else
+ runner.benchmark(all: options.all)
end
end
- return output.to_json
-end
-project = Mach5Tools::Project.new(File.join(Dir.pwd, 'mach5.yml'))
-mach5_data = db(project.run_all)
-
-File.open("mach5.js", 'w') do |file|
- file.write("var mach5 = {};\nmach5[\"data\"] = #{mach5_data.to_s}")
+ default_task :benchmark
end
-File.open("mach5.html", 'w') do |file|
- file.write(File.open(File.join(File.dirname(__FILE__), '..', 'lib', 'mach5.html')).readlines.join)
-end
+App.start
\ No newline at end of file