Sha256: 1344909d675b000e1fe57681ff03711ea4556f42def79628c87a911681808d40

Contents?: true

Size: 959 Bytes

Versions: 28

Compression:

Stored size: 959 Bytes

Contents

require_relative '../lib/prometheus_exporter'
require_relative '../lib/prometheus_exporter/client'
require_relative '../lib/prometheus_exporter/server'

# test how long it takes a custom collector to process 10k messages

class Collector
  def initialize(done)
    @i = 0
    @done = done
  end

  def process(message)
    _parsed = JSON.parse(message)
    @i += 1
    @done.call if @i % 10_000 == 0
  end

  def prometheus_metrics_text
  end
end

@start = nil
@client = nil
@runs = 1000

done = lambda do
  puts "Elapsed for 10k messages is #{Time.now - @start}"
  if (@runs -= 1) > 0
    @start = Time.now
    10_000.times { @client.send_json(hello: "world") }
  end
end

collector = Collector.new(done)
server = PrometheusExporter::Server::WebServer.new port: 12349, collector: collector
server.start
@client = PrometheusExporter::Client.new port: 12349, max_queue_size: 100_000

@start = Time.now
10_000.times { @client.send_json(hello: "world") }

sleep

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
prometheus_exporter-0.1.12 bench/bench.rb
prometheus_exporter-0.1.11 bench/bench.rb
prometheus_exporter-0.1.10 bench/bench.rb
prometheus_exporter-0.1.9 bench/bench.rb
prometheus_exporter-0.1.8 bench/bench.rb
prometheus_exporter-0.1.7 bench/bench.rb
prometheus_exporter-0.1.6 bench/bench.rb
prometheus_exporter-0.1.5 bench/bench.rb