summaryrefslogtreecommitdiff
path: root/lib/Support/Unix/TimeValue.inc
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-04-27 23:59:25 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-04-27 23:59:25 +0000
commit7f1946408dd5ba7258542b1e1637308d7cd1cd69 (patch)
tree185eacde51196b005d2044c4c0cd5b2efe506f5a /lib/Support/Unix/TimeValue.inc
parentbefce904c0bcbd8053ad049ae63329ad25e1aabe (diff)
downloadllvm-7f1946408dd5ba7258542b1e1637308d7cd1cd69.tar.gz
llvm-7f1946408dd5ba7258542b1e1637308d7cd1cd69.tar.bz2
llvm-7f1946408dd5ba7258542b1e1637308d7cd1cd69.tar.xz
Teach the pass manager's execution dump to print the current time before
each line. This is particularly nice for tracking which run of a particular pass over a particular function was slow. This also required making the TimeValue string much more useful. First, there is a standard format for writing out a date and time. Let's use that rather than strings that would have to be parsed. Second, actually output the nanosecond resolution that timevalue claims to have. This is proving useful working on PR19499, so I figured it would be generally useful to commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207385 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix/TimeValue.inc')
-rw-r--r--lib/Support/Unix/TimeValue.inc8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Support/Unix/TimeValue.inc b/lib/Support/Unix/TimeValue.inc
index 80532b0b95..58c7ba3094 100644
--- a/lib/Support/Unix/TimeValue.inc
+++ b/lib/Support/Unix/TimeValue.inc
@@ -26,9 +26,11 @@ std::string TimeValue::str() const {
struct tm Storage;
struct tm *LT = ::localtime_r(&OurTime, &Storage);
assert(LT);
- char Buffer[25];
- strftime(Buffer, 25, "%b %e %H:%M %Y", LT);
- return std::string(Buffer);
+ char Buffer1[sizeof("YYYY-MM-DD HH:MM:SS")];
+ strftime(Buffer1, sizeof(Buffer1), "%Y-%m-%d %H:%M:%S", LT);
+ char Buffer2[sizeof("YYYY-MM-DD HH:MM:SS.MMMUUUNNN")];
+ snprintf(Buffer2, sizeof(Buffer2), "%s.%.9u", Buffer1, this->nanoseconds());
+ return std::string(Buffer2);
}
TimeValue TimeValue::now() {