Sha256: 8bffa7957b85a6fb03d7517a8852b97934225425aad15b13505c4d7507d9d97e

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

#! /usr/bin/env ruby

puts "Loading..."

require 'benchmark'
require 'rubygems'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'gelf'

puts "Generating random data..."
srand(1)
RANDOM_DATA = ('A'..'z').to_a
k3_message = (1..3*1024).map { RANDOM_DATA[rand(RANDOM_DATA.count)] }.join

TARGET_HOST = 'localhost'
TARGET_PORT = 12201
DEFAULT_OPTIONS = { '_host' => 'localhost' }
TIMES = 5000

SHORT_HASH = { '_short_message' => 'message' }
LONG_HASH  = { '_short_message' => 'message', '_long_message' => k3_message }


notifier_lan = GELF::Notifier.new(TARGET_HOST, TARGET_PORT, 'LAN', DEFAULT_OPTIONS)
notifier_wan = GELF::Notifier.new(TARGET_HOST, TARGET_PORT, 'WAN', DEFAULT_OPTIONS)

# to create mongo collections, etc.
notifier_lan.notify!(LONG_HASH)
sleep(5)

puts "Sending #{TIMES} notifications...\n"
tms = Benchmark.bm(25) do |b|
  b.report('lan, short data, 1 chunk ') { TIMES.times { notifier_lan.notify!(SHORT_HASH) } }
  sleep(5)
  b.report('lan,  long data, 1 chunk ') { TIMES.times { notifier_lan.notify!(LONG_HASH) } }
  sleep(5)
  b.report('wan,  long data, 2 chunks') { TIMES.times { notifier_wan.notify!(LONG_HASH) } }
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gelf-1.1.3 benchmarks/notifier.rb
gelf-1.1.1 benchmarks/notifier.rb
gelf-1.1.0 benchmarks/notifier.rb
gelf-1.1.0.rc1 benchmarks/notifier.rb
gelf-1.1.0.gamma1 benchmarks/notifier.rb
gelf-1.1.0.beta6 benchmarks/notifier.rb