LCOV - code coverage report
Current view: top level - lib/Support - Chrono.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 9 9 100.0 %
Date: 2017-09-14 15:23:50 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- Support/Chrono.cpp - Utilities for Timing Manipulation ---*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #include "llvm/Support/Chrono.h"
      11             : #include "llvm/Config/config.h"
      12             : #include "llvm/Support/Format.h"
      13             : #include "llvm/Support/raw_ostream.h"
      14             : 
      15             : namespace llvm {
      16             : 
      17             : using namespace sys;
      18             : 
      19             : const char llvm::detail::unit<std::ratio<3600>>::value[] = "h";
      20             : const char llvm::detail::unit<std::ratio<60>>::value[] = "m";
      21             : const char llvm::detail::unit<std::ratio<1>>::value[] = "s";
      22             : const char llvm::detail::unit<std::milli>::value[] = "ms";
      23             : const char llvm::detail::unit<std::micro>::value[] = "us";
      24             : const char llvm::detail::unit<std::nano>::value[] = "ns";
      25             : 
      26             : static inline struct tm getStructTM(TimePoint<> TP) {
      27             :   struct tm Storage;
      28         128 :   std::time_t OurTime = toTimeT(TP);
      29             : 
      30             : #if defined(LLVM_ON_UNIX)
      31         128 :   struct tm *LT = ::localtime_r(&OurTime, &Storage);
      32             :   assert(LT);
      33             :   (void)LT;
      34             : #endif
      35             : #if defined(LLVM_ON_WIN32)
      36             :   int Error = ::localtime_s(&Storage, &OurTime);
      37             :   assert(!Error);
      38             :   (void)Error;
      39             : #endif
      40             : 
      41             :   return Storage;
      42             : }
      43             : 
      44         128 : raw_ostream &operator<<(raw_ostream &OS, TimePoint<> TP) {
      45         128 :   struct tm LT = getStructTM(TP);
      46             :   char Buffer[sizeof("YYYY-MM-DD HH:MM:SS")];
      47         128 :   strftime(Buffer, sizeof(Buffer), "%Y-%m-%d %H:%M:%S", &LT);
      48         256 :   return OS << Buffer << '.'
      49         384 :             << format("%.9lu",
      50         384 :                       long((TP.time_since_epoch() % std::chrono::seconds(1))
      51         384 :                                .count()));
      52             : }
      53             : 
      54             : } // namespace llvm

Generated by: LCOV version 1.13