class Bench::Commands::Report
Constants
- REPORT_DIR
TODO (pitr 03-Dec-2015): use data file name instead of report.html
Public Instance Methods
after(options, measurements)
click to toggle source
# File lib/bench9000/commands/report.rb, line 18 def after(options, measurements) report = read("report.html") replacements = { '<script src="jquery.js"></script>' => "<script>#{read('jquery.js')}</script>", '<script src="bootstrap.js"></script>' => "<script>#{read('bootstrap.js')}</script>", '<script src="chart.js"></script>' => "<script>#{read('chart.js')}</script>", '<script src="data.js"></script>' => "<script>bench_data = #{JSONFormatter.format(options, measurements)};</script>", '<script src="report.js"></script>' => "<script>#{read('report.js')}</script>", '<link rel="stylesheet" type="text/css" href="bootstrap.css">' => "<style>#{read('bootstrap.css')}</style>", '<link rel="stylesheet" type="text/css" href="bootstrap-theme.css">' => "<style>#{read('bootstrap-theme.css')}</style>" } replacements.each do |find, replace| report[find] = replace end if options.flags.has_key? "--baseline" report["var speedup_reference_implementation = bench_data.implementations[0];"] = "var speedup_reference_implementation = \"#{options.flags['--baseline']}\";" end report["<!-- notes -->"] = "<p>Report generated at #{Time.now}</p><!-- notes -->" if options.flags.has_key? "--notes" report["<!-- notes -->"] = File.open(options.flags["--notes"]).read end File.open("report.html", "w").write(report) puts "Total benchmarking time: #{(measurements.total_time/60).round}m" end
read(file)
click to toggle source
# File lib/bench9000/commands/report.rb, line 64 def read(file) File.open("#{REPORT_DIR}/#{file}", "r").read() end