• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

llnl / dftracer-utils / 29185833209

12 Jul 2026 08:25AM UTC coverage: 51.235% (-1.5%) from 52.754%
29185833209

Pull #96

github

web-flow
Merge 0b9f07110 into 056c79287
Pull Request #96: fix: consolidate stale-index rebuilds across consumers and fix multi-run breaks

33724 of 84486 branches covered (39.92%)

Branch coverage included in aggregate %.

140 of 147 new or added lines in 15 files covered. (95.24%)

5188 existing lines in 197 files now uncovered.

34547 of 48765 relevant lines covered (70.84%)

10791.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

44.78
/src/dftracer/utils/core/utils/timer.cpp
1
#include <dftracer/utils/core/common/logging.h>
2
#include <dftracer/utils/core/utils/timer.h>
3

4
#include <algorithm>
5
#include <cinttypes>
6
#include <cstdio>
7
#include <utility>
8
#include <vector>
9

10
namespace dftracer::utils {
11

12
Timer::Timer(bool autostart, bool verbose)
69!
13
    : verbose_(verbose), running_(false) {
46✔
14
    if (autostart) {
23!
15
        start();
23!
16
    }
23✔
17
}
46✔
18

19
Timer::Timer(const std::string& name, bool autostart, bool verbose)
69!
20
    : verbose_(verbose), running_(false), name_(name) {
46✔
21
    if (autostart) {
23✔
22
        start();
3!
23
    }
3✔
24
}
46✔
25

26
Timer::Timer(const char* name, bool autostart, bool verbose)
23✔
27
    : Timer(std::string(name), autostart, verbose) {}
23!
28

29
Timer::~Timer() {
112✔
30
    stop();
56!
31
    if (verbose_) {
56!
32
        if (name_.empty()) {
×
33
            std::printf("Elapsed time: %" PRId64 " ns\n", elapsed());
×
UNCOV
34
        } else {
×
35
            std::printf("[%s] Elapsed time: %" PRId64 " ns\n", name_.c_str(),
×
UNCOV
36
                        elapsed());
×
37
        }
UNCOV
38
    }
×
39
}
112✔
40

41
void Timer::start() {
26✔
42
    start_time = Clock::now();
26✔
43
    running_ = true;
26✔
44
}
26✔
45

46
void Timer::stop() {
69✔
47
    if (running_) {
69✔
48
        end_time = Clock::now();
36✔
49
        running_ = false;
36✔
50
    }
36✔
51
}
69✔
52

53
std::int64_t Timer::elapsed() const {
24✔
54
    if (running_) {
24✔
55
        return std::chrono::duration_cast<std::chrono::nanoseconds>(
22✔
56
                   Clock::now() - start_time)
11✔
57
            .count();
11✔
58
    } else {
59
        return std::chrono::duration_cast<std::chrono::nanoseconds>(end_time -
39✔
60
                                                                    start_time)
13✔
61
            .count();
13✔
62
    }
63
}
24✔
64

65
void Timer::increment(const std::string& key, std::uint64_t by) {
12✔
66
    counters_[key] += by;
12✔
67
}
12✔
68

69
void Timer::set_counter(const std::string& key, std::uint64_t value) {
×
70
    counters_[key] = value;
×
71
}
×
72

73
const std::unordered_map<std::string, std::uint64_t>& Timer::counters() const {
3✔
74
    return counters_;
3✔
75
}
76

77
void Timer::print_stages(const std::string& prefix) const {
×
78
    if (counters_.empty()) return;
×
79

UNCOV
80
    std::vector<std::pair<std::string, std::uint64_t>> sorted(counters_.begin(),
×
81
                                                              counters_.end());
×
82
    std::sort(sorted.begin(), sorted.end());
×
83

84
    std::uint64_t total_ns = 0;
×
85
    for (const auto& [_, ns] : sorted) total_ns += ns;
×
86

87
    if (!name_.empty()) {
×
88
        std::printf("%s%s (%.2f ms)\n", prefix.c_str(), name_.c_str(),
×
89
                    static_cast<double>(total_ns) / 1e6);
×
UNCOV
90
    }
×
91
    for (std::size_t i = 0; i < sorted.size(); ++i) {
×
92
        const auto& [key, ns] = sorted[i];
×
93
        bool last = (i + 1 == sorted.size());
×
94
        double ms = static_cast<double>(ns) / 1e6;
×
95
        double pct = total_ns > 0 ? 100.0 * static_cast<double>(ns) /
×
96
                                        static_cast<double>(total_ns)
×
97
                                  : 0.0;
98
        std::printf("%s%s %-28s %8.2f ms  (%5.1f%%)\n", prefix.c_str(),
×
UNCOV
99
                    last ? "\\-- " : "|-- ", key.c_str(), ms, pct);
×
UNCOV
100
    }
×
101
}
×
102

103
}  // namespace dftracer::utils
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc