forked from omega13a/stargen
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added optional performance monitoring, create html folder if doesn't …
…exist
- Loading branch information
Showing
6 changed files
with
1,795 additions
and
1,665 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "PerformanceMonitor.h" | ||
#include <iostream> | ||
|
||
// Global instance definition | ||
PerformanceMonitor performanceMonitor; | ||
|
||
void PerformanceMonitor::setEnabled(bool enable) { | ||
enabled = enable; | ||
if (enable) { | ||
lastFileTime = Clock::now(); | ||
} | ||
} | ||
|
||
void PerformanceMonitor::recordFileOperation(const std::string& fileName) { | ||
if (!enabled) return; | ||
|
||
auto currentTime = Clock::now(); | ||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( | ||
currentTime - lastFileTime); | ||
|
||
if (!lastFileName.empty()) { | ||
std::cout << "Time between " << lastFileName << " and " << fileName | ||
<< ": " << duration.count() << "ms\n"; | ||
} | ||
|
||
lastFileName = fileName; | ||
lastFileTime = currentTime; | ||
} | ||
|
||
bool PerformanceMonitor::isEnabled() const { | ||
return enabled; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <chrono> | ||
#include <string> | ||
|
||
class PerformanceMonitor { | ||
private: | ||
using Clock = std::chrono::high_resolution_clock; | ||
using TimePoint = std::chrono::time_point<Clock>; | ||
|
||
bool enabled = false; | ||
TimePoint lastFileTime; | ||
std::string lastFileName; | ||
|
||
public: | ||
void setEnabled(bool enable); | ||
void recordFileOperation(const std::string& fileName); | ||
bool isEnabled() const; | ||
}; | ||
|
||
// Global instance declaration | ||
extern PerformanceMonitor performanceMonitor; |
Oops, something went wrong.