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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
# -*- tcl -*-
# loggerperformance.tcl
# $Id: loggerperformance,v 1.2 2004/01/15 06:36:13 andreas_kupries Exp $
# This code is for benchmarking the performance of the log tools.
set auto_path "[file dirname [info script]] $auto_path"
package require logger
package require log
# Set up logger
set log [logger::init date]
# Create a custom log routine, so we don't deal with the overhead of
# the default one, which does some system calls itself.
${log}::logproc notice txt {
puts "$txt"
}
# Basic output.
proc Test1 {} {
set date [clock format [clock seconds]]
puts "Date is now $date"
}
# No output at all. This is the benchmark by which 'turned off' log
# systems should be judged.
proc Test2 {} {
set date [clock format [clock seconds]]
}
# Use logger.
proc Test3 {} {
set date [clock format [clock seconds]]
${::log}::notice "Date is now $date"
}
# Use log.
proc Test4 {} {
set date [clock format [clock seconds]]
log::log notice "Date is now $date"
}
set res1 [time {
Test1
} 1000]
set res2 [time {
Test2
} 1000]
set res3 [time {
Test3
} 1000]
${log}::disable notice
set res4 [time {
Test3
} 1000]
set res5 [time {
Test4
} 1000]
log::lvSuppressLE notice
set res6 [time {
Test4
} 1000]
puts "Puts output: $res1"
puts "No output: $res2"
puts "Logger: $res3"
puts "Logger disabled: $res4"
puts "Log: $res5"
puts "Log disabled: $res6"
|