From 4652be3e6ba87fa5d1044c3e53396f5fe6f059bf Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 10 Jan 2017 22:45:29 +0000 Subject: small code review, performance test cases ready. --- generic/tclClock.c | 2 +- generic/tclClockFmt.c | 6 +++--- tests-perf/clock.perf.tcl | 32 ++++++++++++++++++++------------ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/generic/tclClock.c b/generic/tclClock.c index a3a9332..7d4263c 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -3488,7 +3488,7 @@ ClockSecondsObjCmd( /* *---------------------------------------------------------------------- * - * TzsetIfNecessary -- + * TzsetGetEpoch --, TzsetIfNecessary -- * * Calls the tzset() library function if the contents of the TZ * environment variable has changed. diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c index 7a6fa0b..307fc28 100644 --- a/generic/tclClockFmt.c +++ b/generic/tclClockFmt.c @@ -1366,7 +1366,7 @@ ClockScnToken_StarDate_Proc(ClockFmtScnCmdArgs *opts, GetJulianDayFromEraYearDay(&yydate, GREGORIAN_CHANGE_DATE); - yydate.seconds = + yydate.localSeconds = -210866803200L + ( SECONDS_PER_DAY * (Tcl_WideInt)yydate.julianDay ) + ( SECONDS_PER_DAY * fractDay / fractDayDiv ); @@ -1439,7 +1439,7 @@ static ClockScanTokenMap ScnSTokenMap[] = { /* %t */ {CTOKT_CHAR, 0, 0, 1, 1, 0, NULL, "\t"}, /* %Q */ - {CTOKT_PARSER, CLF_POSIXSEC, 0, 16, 30, 0, + {CTOKT_PARSER, CLF_LOCALSEC, 0, 16, 30, 0, ClockScnToken_StarDate_Proc, NULL}, }; static const char *ScnSTokenMapAliasIndex[2] = { @@ -2109,7 +2109,7 @@ ClockFmtToken_StarDate_Proc( fractYear, '0', 3); *dateFmt->output++ = '.'; dateFmt->output = _itoaw(dateFmt->output, - dateFmt->date.seconds % SECONDS_PER_DAY / ( SECONDS_PER_DAY / 10 ), '0', 1); + dateFmt->date.localSeconds % SECONDS_PER_DAY / ( SECONDS_PER_DAY / 10 ), '0', 1); return TCL_OK; } diff --git a/tests-perf/clock.perf.tcl b/tests-perf/clock.perf.tcl index 34d9429..f3b8a10 100644 --- a/tests-perf/clock.perf.tcl +++ b/tests-perf/clock.perf.tcl @@ -32,7 +32,7 @@ proc {**STOP**} {args} { } proc _test_get_commands {lst} { - regsub -all {(?:^|\n)[ \t]*(\#[^\n]*)(?=\n\s*[\{\#])} $lst "\n{\\1}" + regsub -all {(?:^|\n)[ \t]*(\#[^\n]*|\msetup\M[^\n]*|\mcleanup\M[^\n]*)(?=\n\s*(?:[\{\#]|setup|cleanup))} $lst "\n{\\1}" } proc _test_out_total {} { @@ -83,7 +83,11 @@ proc _test_run {reptime lst {outcmd {puts $_(r)}}} { foreach _(c) [_test_get_commands $lst] { puts "% [regsub -all {\n[ \t]*} $_(c) {; }]" - if {[regexp {\s*\#} $_(c)]} continue + if {[regexp {^\s*\#} $_(c)]} continue + if {[regexp {^\s*(?:setup|cleanup)\s+} $_(c)]} { + puts [if 1 [lindex $_(c) 1]] + continue + } set _(r) [if 1 $_(c)] if {$outcmd ne {}} $outcmd puts [set _(m) [timerate $_(c) $reptime]] @@ -122,11 +126,11 @@ proc test-format {{reptime 1000}} { # Format : time only (CEST) {clock format 1482525936 -format "%H:%M:%S" -timezone :CET} # Format : default (in gmt) - {clock format 1482525936 -gmt 1} + {clock format 1482525936 -gmt 1 -locale en} # Format : default (system zone) - {clock format 1482525936} + {clock format 1482525936 -locale en} # Format : default (CEST) - {clock format 1482525936 -timezone :CET} + {clock format 1482525936 -timezone :CET -locale en} # Format : ISO date-time (in gmt, numeric zone) {clock format 1246379400 -format "%Y-%m-%dT%H:%M:%S %z" -gmt 1} # Format : ISO date-time (system zone, CEST, numeric zone) @@ -149,15 +153,19 @@ proc test-format {{reptime 1000}} { {clock format 1246379400 -format "%b" -locale en -gmt 1} # Format : locale lookup 2 tables - month and day: {clock format 1246379400 -format "%b %Od" -locale en -gmt 1} + # Format : locale lookup 3 tables - week, month and day: + {clock format 1246379400 -format "%a %b %Od" -locale en -gmt 1} + # Format : locale lookup 4 tables - week, month, day and year: + {clock format 1246379400 -format "%a %b %Od %Oy" -locale en -gmt 1} # Format : dynamic clock value (without converter caches): - {set i 0; continue} - {clock format [incr i] -format "%Y-%m-%dT%H:%M:%S" -locale en -gmt 1} - {puts [clock format $i -format "%Y-%m-%dT%H:%M:%S" -locale en -gmt 1]\n; continue} + setup {set i 0} + {clock format [incr i] -format "%Y-%m-%dT%H:%M:%S" -locale en -timezone :CET} + cleanup {puts [clock format $i -format "%Y-%m-%dT%H:%M:%S" -locale en -timezone :CET]} # Format : dynamic clock value (without any converter caches, zone range overflow): - {set i 0; continue} - {clock format [incr i 86400] -format "%Y-%m-%dT%H:%M:%S" -locale en -gmt 1} - {puts [clock format $i -format "%Y-%m-%dT%H:%M:%S" -locale en -gmt 1]\n; continue} + setup {set i 0} + {clock format [incr i 86400] -format "%Y-%m-%dT%H:%M:%S" -locale en -timezone :CET} + cleanup {puts [clock format $i -format "%Y-%m-%dT%H:%M:%S" -locale en -timezone :CET]} # Format : dynamic format (cacheable) {clock format 1246379415 -format [string trim "%d.%m.%Y %H:%M:%S "] -gmt 1} @@ -310,4 +318,4 @@ proc test {{reptime 1000}} { puts \n**OK** } -test 100; # ms +test 500; # ms -- cgit v0.12