-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbenchmark.rb
62 lines (51 loc) · 1.47 KB
/
benchmark.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env ruby
#
require 'benchmark'
# pass an arg to use the pure ruby Syslog module
if !!ARGV[0]
puts "monkey patching Syslog module..."
require 'syslog_compat'
end
require 'syslog-logger'
require 'syslog_ruby'
Benchmark.bm(20) do |x|
x.report('single syslog') do
Syslog.open
225.times do
Syslog.info "(single syslog) Logged via Syslog"
end
Syslog.close if Syslog.opened?
end
sleep 1
x.report('single syslogger') do
l1 = Logger::Syslog.new('test', Syslog::LOG_SYSLOG)
225.times do
l1.info "(single syslogger) Logged via Logger::Syslog (1)"
end
end
sleep 1
x.report('single pure ruby') do
rl1 = SyslogRuby::Logger.new('pure-test1', :SYSLOG, uri: '/dev/log')
225.times do
rl1.info "(single pure ruby) logged via SyslogRuby::Logger (1)"
end
end
sleep 1
x.report('2 sysloggers') do
l1 = Logger::Syslog.new('test2-1', Syslog::LOG_SYSLOG)
l2 = Logger::Syslog.new('test2-2', Syslog::LOG_SYSLOG)
225.times do
l1.info "(2 sysloggers) logged via Logger::Syslog (1)"
l2.info "(2 sysloggers) logged via Logger::Syslog (2)"
end
end
sleep 1
x.report('2 pure ruby') do
rl1 = SyslogRuby::Logger.new('pure-test2-1', :SYSLOG, uri: '/dev/log')
rl2 = SyslogRuby::Logger.new('pure-test2-2', :SYSLOG, uri: '/dev/log')
225.times do
rl1.info "(2 pure ruby) logged via SyslogRuby::Logger (1)"
rl2.info "(2 pure ruby) logged via SyslogRuby::Logger (2)"
end
end
end