summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-01-10 22:45:29 (GMT)
committersebres <sebres@users.sourceforge.net>2017-01-10 22:45:29 (GMT)
commit4652be3e6ba87fa5d1044c3e53396f5fe6f059bf (patch)
tree5345a60652953d5c641e7f831e567d246dabe276
parent8ea52694c552cb1c68f8853af7a3887c71b9ba2a (diff)
downloadtcl-4652be3e6ba87fa5d1044c3e53396f5fe6f059bf.zip
tcl-4652be3e6ba87fa5d1044c3e53396f5fe6f059bf.tar.gz
tcl-4652be3e6ba87fa5d1044c3e53396f5fe6f059bf.tar.bz2
small code review, performance test cases ready.
-rw-r--r--generic/tclClock.c2
-rw-r--r--generic/tclClockFmt.c6
-rw-r--r--tests-perf/clock.perf.tcl32
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