[Libreoffice-commits] core.git: sal/osl
Tor Lillqvist
tml at collabora.com
Fri Jun 29 14:39:25 UTC 2018
sal/osl/all/log.cxx | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
New commits:
commit f7f75d92604cb591c5a974d433651dff98708511
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Jun 28 17:14:39 2018 +0300
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 at collabora.com>
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 << ':';
More information about the Libreoffice-commits
mailing list