Sha256: e9e7f329fed0a18089605359619270e842a5bc76a580ca91487ec951b4efd253

Contents?: true

Size: 1.18 KB

Versions: 1

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

1 entries across 1 versions & 1 rubygems

Version Path
gelf-1.1.0.beta4 benchmarks/notifier.rb