summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-06-28 17:14:39 +0300
committerTor Lillqvist <tml@collabora.com>2018-06-29 16:38:58 +0200
commitf7f75d92604cb591c5a974d433651dff98708511 (patch)
tree162c585040abb9496aed81ecda93cdc9c24c19ab /sal
parentf422f2bb775e04f64e03d4b65d81add55543513c (diff)
Make the RELATIVETIMER be relative to start of the process, not to first call
Make it easier to compare timing logs even if you add a SAL_DEBUG() that happens much earlier than the others, the timestamps of the others will still be comparable to those from earlier runs. Change-Id: I13872ef9112d8515e563e561f9b2a50c8510bae8 Reviewed-on: https://gerrit.libreoffice.org/56676 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/all/log.cxx25
1 files changed, 15 insertions, 10 deletions
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index d5c77dfb5750..1a0d0ada6f1c 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -55,6 +55,17 @@ bool const sal_use_syslog = false;
namespace {
+struct TimeContainer
+{
+ TimeValue aTime;
+ TimeContainer()
+ {
+ osl_getSystemTime(&aTime);
+ }
+};
+
+TimeContainer aStartTime;
+
bool equalStrings(
char const * string1, std::size_t length1, char const * string2,
std::size_t length2)
@@ -206,22 +217,16 @@ void maybeOutputTimestamp(std::ostringstream &s) {
s << ts << '.' << milliSecs << ':';
}
if (outputRelativeTimer) {
- static bool beenHere = false;
- static TimeValue first;
- if (!beenHere) {
- osl_getSystemTime(&first);
- beenHere = true;
- }
TimeValue now;
osl_getSystemTime(&now);
- int seconds = now.Seconds - first.Seconds;
+ int seconds = now.Seconds - aStartTime.aTime.Seconds;
int milliSeconds;
- if (now.Nanosec < first.Nanosec) {
+ if (now.Nanosec < aStartTime.aTime.Nanosec) {
seconds--;
- milliSeconds = 1000-(first.Nanosec-now.Nanosec)/1000000;
+ milliSeconds = 1000-(aStartTime.aTime.Nanosec-now.Nanosec)/1000000;
}
else
- milliSeconds = (now.Nanosec-first.Nanosec)/1000000;
+ milliSeconds = (now.Nanosec-aStartTime.aTime.Nanosec)/1000000;
char relativeTimestamp[100];
snprintf(relativeTimestamp, sizeof(relativeTimestamp), "%d.%03d", seconds, milliSeconds);
s << relativeTimestamp << ':';