Sha256: 281634d769b5a6d2aa643bd1518f022418d827ecc3f5dc770c9c97cba6e3243d
Contents?: true
Size: 1.62 KB
Versions: 13
Compression:
Stored size: 1.62 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require "bundler/setup" require "tmpdir" require "benchmark/ips" revision = %x(git rev-parse HEAD).rstrip base_revision = %x(git rev-parse origin/main).rstrip branch = if revision == base_revision "main" else %x(git rev-parse --abbrev-ref HEAD).rstrip end intermediate_results_filename = "#{Dir.tmpdir}/statsd-instrument-benchmarks/#{File.basename($PROGRAM_NAME)}" FileUtils.mkdir_p(File.dirname(intermediate_results_filename)) ENV["ENV"] = "development" require "statsd-instrument" StatsD.logger = Logger.new(File::NULL) report = Benchmark.ips do |bench| bench.report("StatsD metrics to /dev/null log (branch: #{branch}, sha: #{revision[0, 7]})") do StatsD.increment("StatsD.increment", 10, sample_rate: 15) StatsD.measure("StatsD.measure") { 1 + 1 } StatsD.gauge("StatsD.gauge", 12.0, tags: ["foo:bar", "quc"]) StatsD.set("StatsD.set", "value", tags: { foo: "bar", baz: "quc" }) if StatsD.singleton_client.datagram_builder_class == StatsD::Instrument::DogStatsDDatagramBuilder StatsD.event("StasD.event", "12345") StatsD.service_check("StatsD.service_check", "ok") end end # Store the results in between runs bench.save!(intermediate_results_filename) bench.compare! end if report.entries.length == 1 puts puts "To compare the performance of this revision against another revision (e.g. main)," puts "check out a different branch and run this benchmark script again." elsif ENV["KEEP_RESULTS"] puts puts "The intermediate results have been stored in #{intermediate_results_filename}" else File.unlink(intermediate_results_filename) end
Version data entries
13 entries across 13 versions & 1 rubygems