Sha256: 2297763056aa0230178214da0bce7328de8839e7d45d766578dc088f2b96b284

Contents?: true

Size: 975 Bytes

Versions: 7

Compression:

Stored size: 975 Bytes

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 'syslog-sd'

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 = SyslogSD::Notifier.new(TARGET_HOST, TARGET_PORT, DEFAULT_OPTIONS)

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

puts "Sending #{TIMES} notifications...\n"
tms = Benchmark.bm(25) do |b|
  b.report('short data') { TIMES.times { notifier.notify!(SHORT_HASH) } }
  sleep(5)
  b.report('long data ') { TIMES.times { notifier.notify!(LONG_HASH) } }
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
syslog-sd-1.3.2 benchmarks/notifier.rb
syslog-sd-1.3.1 benchmarks/notifier.rb
syslog-sd-1.2.4 benchmarks/notifier.rb
syslog-sd-1.2.3 benchmarks/notifier.rb
syslog-sd-1.2.2 benchmarks/notifier.rb
syslog-sd-1.2.1 benchmarks/notifier.rb
syslog-sd-1.2.0 benchmarks/notifier.rb