Deleted Added
full compact
Timer.h (341825) Timer.h (353358)
1//===- Timer.h ----------------------------------------------*- C++ -*-===//
2//
1//===- Timer.h ----------------------------------------------*- C++ -*-===//
2//
3// The LLVM Linker
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4//
6//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLD_COMMON_TIMER_H
11#define LLD_COMMON_TIMER_H
12
13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/StringRef.h"
15#include <assert.h>
16#include <chrono>
17#include <map>
18#include <memory>
19
20namespace lld {
21
22class Timer;
23
24struct ScopedTimer {
7//===----------------------------------------------------------------------===//
8
9#ifndef LLD_COMMON_TIMER_H
10#define LLD_COMMON_TIMER_H
11
12#include "llvm/ADT/DenseMap.h"
13#include "llvm/ADT/StringRef.h"
14#include <assert.h>
15#include <chrono>
16#include <map>
17#include <memory>
18
19namespace lld {
20
21class Timer;
22
23struct ScopedTimer {
25 explicit ScopedTimer(Timer &T);
24 explicit ScopedTimer(Timer &t);
26
27 ~ScopedTimer();
28
29 void stop();
30
25
26 ~ScopedTimer();
27
28 void stop();
29
31 Timer *T = nullptr;
30 Timer *t = nullptr;
32};
33
34class Timer {
35public:
31};
32
33class Timer {
34public:
36 Timer(llvm::StringRef Name, Timer &Parent);
35 Timer(llvm::StringRef name, Timer &parent);
37
38 static Timer &root();
39
40 void start();
41 void stop();
42 void print();
43
44 double millis() const;
45
46private:
36
37 static Timer &root();
38
39 void start();
40 void stop();
41 void print();
42
43 double millis() const;
44
45private:
47 explicit Timer(llvm::StringRef Name);
48 void print(int Depth, double TotalDuration, bool Recurse = true) const;
46 explicit Timer(llvm::StringRef name);
47 void print(int depth, double totalDuration, bool recurse = true) const;
49
48
50 std::chrono::time_point<std::chrono::high_resolution_clock> StartTime;
51 std::chrono::nanoseconds Total;
52 std::vector<Timer *> Children;
53 std::string Name;
54 Timer *Parent;
49 std::chrono::time_point<std::chrono::high_resolution_clock> startTime;
50 std::chrono::nanoseconds total;
51 std::vector<Timer *> children;
52 std::string name;
53 Timer *parent;
55};
56
57} // namespace lld
58
59#endif
54};
55
56} // namespace lld
57
58#endif