File: loggerperformance

package info (click to toggle)
tcllib 1.19-dfsg-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 67,328 kB
  • sloc: tcl: 208,371; ansic: 14,215; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 583; makefile: 106; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (79 lines) | stat: -rw-r--r-- 1,421 bytes parent folder | download | duplicates (7)
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"