Sha256: 68f00097e3977e02dccea3e6656d56e15bf51954805ebc24af05a2cddf3715e9

Contents?: true

Size: 990 Bytes

Versions: 28

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literal: true

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-2.1.1 bench/bench.rb
prometheus_exporter-2.1.0 bench/bench.rb
prometheus_exporter-2.0.8 bench/bench.rb
prometheus_exporter-2.0.7 bench/bench.rb
prometheus_exporter-2.0.6 bench/bench.rb
prometheus_exporter-2.0.5 bench/bench.rb
prometheus_exporter-2.0.4 bench/bench.rb
prometheus_exporter-2.0.3 bench/bench.rb
prometheus_exporter-2.0.2 bench/bench.rb
prometheus_exporter-2.0.1 bench/bench.rb
prometheus_exporter-2.0.0 bench/bench.rb
prometheus_exporter-1.0.1 bench/bench.rb
prometheus_exporter-1.0.0 bench/bench.rb
prometheus_exporter-0.8.1 bench/bench.rb
prometheus_exporter-0.8.0 bench/bench.rb
prometheus_exporter-0.7.0 bench/bench.rb
prometheus_exporter-0.6.0 bench/bench.rb
prometheus_exporter-0.5.3 bench/bench.rb
prometheus_exporter-0.5.2 bench/bench.rb
prometheus_exporter-0.5.1 bench/bench.rb