lib/benchmark_driver/output/rubybench.rb in benchmark_driver-output-rubybench-0.2.1 vs lib/benchmark_driver/output/rubybench.rb in benchmark_driver-output-rubybench-0.2.2
- old
+ new
@@ -10,10 +10,12 @@
# Benchmark-specific environment variables:
# BENCHMARK_TYPE_SCRIPT_URL
# BENCHMARK_TYPE_DIGEST
# REPO_NAME
# ORGANIZATION_NAME
+# Optional environment variables:
+# RUBY_ENVIRONMENT
class BenchmarkDriver::Output::Rubybench < BenchmarkDriver::BulkOutput
# For maintainability, this doesn't support streaming progress output.
# @param [Hash{ BenchmarkDriver::Job => Hash{ BenchmarkDriver::Context => BenchmarkDriver::Result } }] job_context_result
# @param [Array<BenchmarkDriver::Metric>] metrics
def bulk_output(job_context_result:, metrics:)
@@ -47,18 +49,22 @@
context_result.each do |context, result|
initiator_hash["benchmark_run[result][#{context.name}]"] = result.values.fetch(metric)
end
ruby_version = context_result.keys.first.executable.description
- environment = context_result.values.first.environment
+ if ENV['RUBY_ENVIRONMENT'] == 'true'
+ environment = ruby_version
+ else
+ environment = { 'Ruby version' => ruby_version }.merge(context_result.values.first.environment).to_yaml
+ end
request.set_form_data({
'benchmark_result_type[name]' => metric.name,
'benchmark_result_type[unit]' => metric.unit,
'benchmark_type[category]' => job.name,
'benchmark_type[script_url]' => ENV.fetch('BENCHMARK_TYPE_SCRIPT_URL'),
'benchmark_type[digest]' => ENV.fetch('BENCHMARK_TYPE_DIGEST'),
- 'benchmark_run[environment]' => { 'Ruby version' => ruby_version }.merge(environment).to_yaml,
+ 'benchmark_run[environment]' => environment,
'repo' => ENV.fetch('REPO_NAME'),
'organization' => ENV.fetch('ORGANIZATION_NAME'),
}.merge(initiator_hash).merge(result_hash))
puts http.request(request).body