Sha256: 22a24a83306bc3b8f6fab88f68469247ef5a6a65e7b9e6446e1aed54be9b2df0

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

#! /usr/bin/env ruby

require 'benchmark'

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

srand(1)
RANDOM_DATA = ('A'..'z').to_a
k1_message = (0..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' => 'short message', 'long_message' => k1_message, 'user_id' => rand(10000)}


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

puts "Sending #{TIMES} notifications..."
tms = Benchmark.bmbm do |b|
  b.report('lan, short data') { TIMES.times { notifier_lan.notify!(SHORT_HASH) } }
  b.report('wan, short data') { TIMES.times { notifier_wan.notify!(SHORT_HASH) } }
  b.report('lan,  long data') { TIMES.times { notifier_lan.notify!(LONG_HASH) } }
  b.report('wan,  long data') { TIMES.times { notifier_wan.notify!(LONG_HASH) } }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gelf-1.1.0.beta3 benchmarks/notifier.rb
gelf-1.1.0.beta2 benchmarks/notifier.rb
gelf-1.1.0.beta1 benchmarks/notifier.rb