Sha256: b578700c1f8f94928da6627082f1759c32b19998dc06f4a9ed48093f1324a05d
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'benchmark/ips' require 'socket' # Set up an UDP listener to which we can send StatsD packets legacy_receiver = UDPSocket.new legacy_receiver.bind('localhost', 0) ENV['ENV'] = "production" ENV['STATSD_ADDR'] = "#{legacy_receiver.addr[2]}:#{legacy_receiver.addr[1]}" ENV['STATSD_IMPLEMENTATION'] ||= 'datadog' require 'statsd-instrument' require 'statsd/instrument/client' legacy_client = StatsD # Set up an UDP listener to which we can send StatsD packets new_client_receiver = UDPSocket.new new_client_receiver.bind('localhost', 0) udp_sink = StatsD::Instrument::UDPSink.new(new_client_receiver.addr[2], new_client_receiver.addr[1]) new_client = StatsD::Instrument::Client.new(sink: udp_sink, default_sample_rate: StatsD.default_sample_rate) Benchmark.ips do |bench| bench.report("Legacy client (sample rate: #{StatsD.default_sample_rate})") do legacy_client.increment('StatsD.increment') end bench.report("New client (sample rate: #{StatsD.default_sample_rate})") do new_client.increment('StatsD.increment') end bench.compare! end legacy_receiver.close new_client_receiver.close
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
statsd-instrument-2.6.0 | benchmark/datagram-client |