Skip to content

Commit 6045844

Browse files
feat(core): make Codspeed class a singleton
This makes sure that we only give metadata to valgrind once.
1 parent 272f7b9 commit 6045844

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/include/codspeed.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
class CodSpeed {
88
public:
9-
// Constructor
10-
CodSpeed();
9+
// Public static method to access the single instance
10+
static CodSpeed *getInstance() {
11+
static CodSpeed instance;
12+
return &instance;
13+
}
1114

1215
// Member functions
1316
void push_group(const std::string &group);
@@ -16,6 +19,8 @@ class CodSpeed {
1619
void end_benchmark();
1720

1821
private:
22+
// Private constructor to prevent direct instantiation
23+
CodSpeed();
1924
std::vector<std::string> benchmarked;
2025
std::string current_benchmark;
2126
std::vector<std::string> group_stack;

0 commit comments

Comments
 (0)