From 9a625d23f10c30494d1e132eb1bb57bf7486d26b Mon Sep 17 00:00:00 2001 From: gahr Date: Wed, 20 Apr 2016 19:27:31 +0000 Subject: Implement msec and usec verbosity levels in tcltest::configure --- doc/tcltest.n | 8 ++++++-- library/tcltest/tcltest.tcl | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/doc/tcltest.n b/doc/tcltest.n index cedc763..ac8b73b 100644 --- a/doc/tcltest.n +++ b/doc/tcltest.n @@ -872,8 +872,8 @@ harness are doing. . Sets the type of output verbosity desired to \fIlevel\fR, a list of zero or more of the elements \fBbody\fR, \fBpass\fR, -\fBskip\fR, \fBstart\fR, \fBerror\fR and \fBline\fR. Default value -is +\fBskip\fR, \fBstart\fR, \fBerror\fR, \fBline\fR, \fBmsec\fR and \fBusec\fR. +Default value is .QW "\fBbody error\fR" . Levels are defined as: .RS @@ -890,6 +890,10 @@ Print errorInfo and errorCode, if they exist, when a test return code does not match its expected return code .IP "line (\fBl\fR)" Print source file line information of failed tests +.IP "msec (\fBm\fR)" +Print each test's execution time in milliseconds +.IP "usec (\fBu\fR)" +Print each test's execution time in microseconds .PP The single letter abbreviations noted above are also recognized so that diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 29ef778..30965b8 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -611,16 +611,27 @@ namespace eval tcltest { proc AcceptVerbose { level } { set level [AcceptList $level] + set levelMap { + l list + p pass + b body + s skip + t start + e error + l line + m msec + u usec + } + set levelRegexp "^([join [dict values $levelMap] |])\$" if {[llength $level] == 1} { - if {![regexp {^(pass|body|skip|start|error|line)$} $level]} { + if {![regexp $levelRegexp $level]} { # translate single characters abbreviations to expanded list - set level [string map {p pass b body s skip t start e error l line} \ - [split $level {}]] + set level [string map $levelMap [split $level {}]] } } set valid [list] foreach v $level { - if {[regexp {^(pass|body|skip|start|error|line)$} $v]} { + if {[regexp $levelRegexp $v]} { lappend valid $v } } @@ -1972,6 +1983,14 @@ proc tcltest::test {name description args} { # Only run the test body if the setup was successful if {!$setupFailure} { + # Register startup time + if {[IsVerbose msec]} { + set msStart [clock milliseconds] + } + if {[IsVerbose usec]} { + set usStart [clock microseconds] + } + # Verbose notification of $body start if {[IsVerbose start]} { puts [outputChannel] "---- $name start" @@ -2076,6 +2095,15 @@ proc tcltest::test {name description args} { } } + if {[IsVerbose msec]} { + set elapsed [expr {[clock milliseconds] - $msStart}] + puts [outputChannel] "++++ $name took $elapsed ms" + } + if {[IsVerbose usec]} { + set elapsed [expr {[clock microseconds] - $usStart}] + puts [outputChannel] "++++ $name took $elapsed μs" + } + # if we didn't experience any failures, then we passed variable numTests if {!($setupFailure || $cleanupFailure || $coreFailure -- cgit v0.12 From 46069c41c59226ee28c31faca3a66afc9582bc31 Mon Sep 17 00:00:00 2001 From: gahr Date: Wed, 20 Apr 2016 19:37:31 +0000 Subject: Bump tcltest version to 2.3.9 --- library/tcltest/pkgIndex.tcl | 2 +- library/tcltest/tcltest.tcl | 2 +- unix/Makefile.in | 4 ++-- win/Makefile.in | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/tcltest/pkgIndex.tcl b/library/tcltest/pkgIndex.tcl index 987725f..06097fd 100644 --- a/library/tcltest/pkgIndex.tcl +++ b/library/tcltest/pkgIndex.tcl @@ -9,4 +9,4 @@ # full path name of this file's directory. if {![package vsatisfies [package provide Tcl] 8.5]} {return} -package ifneeded tcltest 2.3.8 [list source [file join $dir tcltest.tcl]] +package ifneeded tcltest 2.3.9 [list source [file join $dir tcltest.tcl]] diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 30965b8..3d8ae5f 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -22,7 +22,7 @@ namespace eval tcltest { # When the version number changes, be sure to update the pkgIndex.tcl file, # and the install directory in the Makefiles. When the minor version # changes (new feature) be sure to update the man page as well. - variable Version 2.3.8 + variable Version 2.3.9 # Compatibility support for dumb variables defined in tcltest 1 # Do not use these. Call [package provide Tcl] and [info patchlevel] diff --git a/unix/Makefile.in b/unix/Makefile.in index d9f8bbc..2c96973 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -849,8 +849,8 @@ install-libraries: libraries done; @echo "Installing package msgcat 1.6.0 as a Tcl Module"; @$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.6.0.tm; - @echo "Installing package tcltest 2.3.8 as a Tcl Module"; - @$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.3.8.tm; + @echo "Installing package tcltest 2.3.9 as a Tcl Module"; + @$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.3.9.tm; @echo "Installing package platform 1.0.14 as a Tcl Module"; @$(INSTALL_DATA) $(TOP_DIR)/library/platform/platform.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.4/platform-1.0.14.tm; diff --git a/win/Makefile.in b/win/Makefile.in index 2d27a41..1368671 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -660,8 +660,8 @@ install-libraries: libraries install-tzdata install-msgs done; @echo "Installing package msgcat 1.6.0 as a Tcl Module"; @$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/msgcat-1.6.0.tm; - @echo "Installing package tcltest 2.3.8 as a Tcl Module"; - @$(COPY) $(ROOT_DIR)/library/tcltest/tcltest.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/tcltest-2.3.8.tm; + @echo "Installing package tcltest 2.3.9 as a Tcl Module"; + @$(COPY) $(ROOT_DIR)/library/tcltest/tcltest.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/tcltest-2.3.9.tm; @echo "Installing package platform 1.0.14 as a Tcl Module"; @$(COPY) $(ROOT_DIR)/library/platform/platform.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.4/platform-1.0.14.tm; @echo "Installing package platform::shell 1.1.4 as a Tcl Module"; -- cgit v0.12 From df18ecdce0832c7722af0396d30c814d1cebe3a3 Mon Sep 17 00:00:00 2001 From: gahr Date: Tue, 3 May 2016 19:50:15 +0000 Subject: =?UTF-8?q?Approximate=20ms=20by=20=CE=BCs/1000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/tcltest/tcltest.tcl | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/library/tcltest/tcltest.tcl b/library/tcltest/tcltest.tcl index 3d8ae5f..1ba3c41 100644 --- a/library/tcltest/tcltest.tcl +++ b/library/tcltest/tcltest.tcl @@ -1984,11 +1984,8 @@ proc tcltest::test {name description args} { if {!$setupFailure} { # Register startup time - if {[IsVerbose msec]} { - set msStart [clock milliseconds] - } - if {[IsVerbose usec]} { - set usStart [clock microseconds] + if {[IsVerbose msec] || [IsVerbose usec]} { + set timeStart [clock microseconds] } # Verbose notification of $body start @@ -2095,13 +2092,14 @@ proc tcltest::test {name description args} { } } - if {[IsVerbose msec]} { - set elapsed [expr {[clock milliseconds] - $msStart}] - puts [outputChannel] "++++ $name took $elapsed ms" - } - if {[IsVerbose usec]} { - set elapsed [expr {[clock microseconds] - $usStart}] - puts [outputChannel] "++++ $name took $elapsed μs" + if {[IsVerbose msec] || [IsVerbose usec]} { + set t [expr {[clock microseconds] - $timeStart}] + if {[IsVerbose usec]} { + puts [outputChannel] "++++ $name took $t μs" + } + if {[IsVerbose msec]} { + puts [outputChannel] "++++ $name took [expr {round($t/1000.)}] ms" + } } # if we didn't experience any failures, then we passed -- cgit v0.12 From bcaca1bf7b9159ba02add2f07ddff74fc872093f Mon Sep 17 00:00:00 2001 From: gahr Date: Wed, 4 May 2016 12:23:40 +0000 Subject: Add a note in tcltest manual page to betray false expectations on msec and usec. --- doc/tcltest.n | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/tcltest.n b/doc/tcltest.n index ac8b73b..05c1922 100644 --- a/doc/tcltest.n +++ b/doc/tcltest.n @@ -895,6 +895,12 @@ Print each test's execution time in milliseconds .IP "usec (\fBu\fR)" Print each test's execution time in microseconds .PP +Note that the \fBmsec\fR and \fBusec\fR verbosity levels are provided as +indicative measures only. They do not tackle the problem of repeatibility which +should be considered in performance tests or benchmarks. To use these verbosity +levels to thoroughly track performance degradations, consider wrapping your +test bodies with \fBtime\fR commands. +.PP The single letter abbreviations noted above are also recognized so that .QW "\fBconfigure \-verbose pt\fR" -- cgit v0.12