diff options
author | Zachary Turner <zturner@google.com> | 2018-01-17 19:16:26 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2018-01-17 19:16:26 +0000 |
commit | 727f153b6fe28918a28c5b984d79274a10e8f0f1 (patch) | |
tree | c8cd57805574c63be49bc09b156523ee370283bb /lld/include/lld | |
parent | 88dddb89483e8d21b13b6557f67ec5420ffaa7ef (diff) | |
download | bcm5719-llvm-727f153b6fe28918a28c5b984d79274a10e8f0f1.tar.gz bcm5719-llvm-727f153b6fe28918a28c5b984d79274a10e8f0f1.zip |
[coff] Print detailed timing information with /TIME.
The classes used to print and update time information are in
common, so other linkers could use this as well if desired.
Differential Revision: https://reviews.llvm.org/D41915
llvm-svn: 322736
Diffstat (limited to 'lld/include/lld')
-rw-r--r-- | lld/include/lld/Common/Timer.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lld/include/lld/Common/Timer.h b/lld/include/lld/Common/Timer.h new file mode 100644 index 00000000000..6654af62691 --- /dev/null +++ b/lld/include/lld/Common/Timer.h @@ -0,0 +1,59 @@ +//===- Timer.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLD_COMMON_TIMER_H +#define LLD_COMMON_TIMER_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" +#include <assert.h> +#include <chrono> +#include <map> +#include <memory> + +namespace lld { + +class Timer; + +struct ScopedTimer { + explicit ScopedTimer(Timer &T); + + ~ScopedTimer(); + + void stop(); + + Timer *T = nullptr; +}; + +class Timer { +public: + Timer(llvm::StringRef Name, Timer &Parent); + + static Timer &root(); + + void start(); + void stop(); + void print(); + + double millis() const; + +private: + explicit Timer(llvm::StringRef Name); + void print(int Depth, double TotalDuration, bool Recurse = true) const; + + std::chrono::time_point<std::chrono::high_resolution_clock> StartTime; + std::chrono::nanoseconds Total; + std::vector<Timer *> Children; + std::string Name; + Timer *Parent; +}; + +} // namespace lld + +#endif |