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

Alan-Jowett / ebpf-verifier / 18658728485

18 Oct 2025 05:56PM UTC coverage: 88.47% (+0.4%) from 88.11%
18658728485

push

github

elazarg
Bump external/bpf_conformance from `8f3c2fe` to `6fa6a20`

Bumps [external/bpf_conformance](https://github.com/Alan-Jowett/bpf_conformance) from `8f3c2fe` to `6fa6a20`.
- [Release notes](https://github.com/Alan-Jowett/bpf_conformance/releases)
- [Commits](https://github.com/Alan-Jowett/bpf_conformance/compare/8f3c2fe88...<a class=hub.com/Alan-Jowett/ebpf-verifier/commit/6fa6a20ac6fd3612ea9338312a67408687b9f06b">6fa6a20ac)

---
updated-dependencies:
- dependency-name: external/bpf_conformance
  dependency-version: 6fa6a20ac6fd3612ea9338312a67408687b9f06b
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

8954 of 10121 relevant lines covered (88.47%)

18293099.16 hits per line

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

12.68
/src/crab_utils/stats.cpp
1
// Copyright (c) Prevail Verifier contributors.
2
// SPDX-License-Identifier: Apache-2.0
3
#include "stats.hpp"
4

5
#include <algorithm>
6
#include <optional>
7
#include <ostream>
8
#ifdef _WIN32
9
#include <windows.h>
10
#undef max
11
#else
12
#include <sys/resource.h>
13
#include <sys/time.h>
14
#endif
15

16
namespace prevail {
17

18
thread_local LazyAllocator<std::map<std::string, unsigned>> CrabStats::counters;
19
thread_local LazyAllocator<std::map<std::string, Stopwatch>> CrabStats::sw;
20

21
void CrabStats::clear_thread_local_state() {
1,392✔
22
    counters.clear();
1,392✔
23
    sw.clear();
1,392✔
24
}
1,392✔
25

26
// Gets the amount of user CPU time used, in microseconds.
27
long Stopwatch::systemTime() const {
×
28
#ifdef _WIN32
29
    FILETIME creation_time, exit_time, kernel_time, user_time;
30
    if (!GetProcessTimes(GetCurrentProcess(), &creation_time, &exit_time, &kernel_time, &user_time)) {
31
        return 0;
32
    }
33

34
    // Convert from 100ns intervals to microseconds.
35
    uint64_t total_us =
36
        ((static_cast<uint64_t>(user_time.dwHighDateTime) << 32) | static_cast<uint64_t>(user_time.dwLowDateTime)) / 10;
37

38
    return (long)total_us;
39
#else
40
    rusage ru;
41
    getrusage(RUSAGE_SELF, &ru);
×
42
    const long r = ru.ru_utime.tv_sec * 1000000L + ru.ru_utime.tv_usec;
×
43
    return r;
×
44
#endif
45
}
46

47
Stopwatch::Stopwatch() { start(); }
×
48

49
void Stopwatch::start() {
×
50
    started = systemTime();
×
51
    finished = -1;
×
52
    timeElapsed = 0;
×
53
}
×
54

55
void Stopwatch::stop() {
×
56
    if (finished < started) {
×
57
        finished = systemTime();
×
58
    }
59
}
×
60

61
void Stopwatch::resume() {
×
62
    if (finished >= started) {
×
63
        timeElapsed += finished - started;
×
64
        started = systemTime();
×
65
        finished = -1;
×
66
    }
67
}
×
68

69
long Stopwatch::getTimeElapsed() const {
×
70
    if (finished < started) {
×
71
        return timeElapsed + systemTime() - started;
×
72
    } else {
73
        return timeElapsed + finished - started;
×
74
    }
75
}
76

77
double Stopwatch::toSeconds() const { return static_cast<double>(getTimeElapsed()) / 1000000; }
×
78

79
void Stopwatch::Print(std::ostream& out) const {
×
80
    const long time = getTimeElapsed();
×
81
    const long h = time / 3600000000L;
×
82
    const long m = time / 60000000L - h * 60;
×
83
    const float s = (static_cast<float>(time) / 1000000L) - m * 60 - h * 3600;
×
84

85
    if (h > 0) {
×
86
        out << h << "h";
×
87
    }
88
    if (m > 0) {
×
89
        out << m << "m";
×
90
    }
91
    out << s << "s";
×
92
}
×
93

94
void CrabStats::reset() {
×
95
    counters.clear();
×
96
    sw.clear();
×
97
}
×
98

99
void CrabStats::count_max(const std::string& name, const unsigned v) {
×
100
    (*counters)[name] = std::max((*counters)[name], v);
×
101
}
×
102

103
unsigned CrabStats::uset(const std::string& n, const unsigned v) { return (*counters)[n] = v; }
×
104
unsigned CrabStats::get(const std::string& n) { return (*counters)[n]; }
×
105

106
/** Outputs all statistics to std output */
107
void CrabStats::Print(std::ostream& OS) {
×
108
    OS << "\n\n************** STATS ***************** \n";
×
109
    for (const auto& kv : (*counters)) {
×
110
        OS << kv.first << ": " << kv.second << "\n";
×
111
    }
112
    for (const auto& kv : (*sw)) {
×
113
        OS << kv.first << ": " << kv.second << "\n";
×
114
    }
115
    OS << "************** STATS END ***************** \n";
×
116
}
×
117

118
void CrabStats::PrintBrunch(std::ostream& OS) {
×
119
    OS << "\n\n************** BRUNCH STATS ***************** \n";
×
120
    for (const auto& kv : *counters) {
×
121
        OS << "BRUNCH_STAT " << kv.first << " " << kv.second << "\n";
×
122
    }
123
    for (const auto& kv : *sw) {
×
124
        OS << "BRUNCH_STAT " << kv.first << " " << kv.second.toSeconds() << "sec \n";
×
125
    }
126
    OS << "************** BRUNCH STATS END ***************** \n";
×
127
}
×
128

129
ScopedCrabStats::ScopedCrabStats(const std::string& name, const bool reset) : m_name(name) {
10,695,482✔
130
    if (reset) {
10,695,482✔
131
        m_name += ".last";
×
132
        CrabStats::start(m_name);
133
    } else {
134
        CrabStats::resume(m_name);
5,347,741✔
135
    }
136
}
10,695,482✔
137

138
ScopedCrabStats::~ScopedCrabStats() { CrabStats::stop(m_name); }
10,695,482✔
139

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

© 2026 Coveralls, Inc