Skip to content

Commit

Permalink
added page faults to statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhavgoel26 committed Apr 4, 2024
1 parent 2a93753 commit ab51f7b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion include/scea/stats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class ScopeBenchmarker {
PerfEvent cacheMissesEvent;
PerfEvent cacheReferencesEvent;
PerfEvent instructionsEvent;
PerfEvent minorPageFaultsEvent;
PerfEvent majorPageFaultsEvent;
std::string scopeName;

static uint64_t getMaxRSS() {
Expand All @@ -108,23 +110,31 @@ class ScopeBenchmarker {
cacheMissesEvent(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES),
cacheReferencesEvent(PERF_TYPE_HARDWARE,
PERF_COUNT_HW_CACHE_REFERENCES),
instructionsEvent(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS) {
instructionsEvent(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS),
minorPageFaultsEvent(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN),
majorPageFaultsEvent(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ) {
timer.start();
cacheMissesEvent.start();
cacheReferencesEvent.start();
instructionsEvent.start();
minorPageFaultsEvent.start();
majorPageFaultsEvent.start();
}

~ScopeBenchmarker() {
timer.stop();
cacheMissesEvent.stop();
cacheReferencesEvent.stop();
instructionsEvent.stop();
minorPageFaultsEvent.stop();
majorPageFaultsEvent.stop();

uint64_t cacheMisses = cacheMissesEvent.readValue();
uint64_t cacheReferences = cacheReferencesEvent.readValue();
uint64_t instructions = instructionsEvent.readValue();
uint64_t max_rss = getMaxRSS();
uint64_t minorPageFaults = minorPageFaultsEvent.readValue();
uint64_t majorPageFaults = majorPageFaultsEvent.readValue();

std::cout << "Benchmark results for " << scopeName << ":\n";
std::cout << "Duration: " << timer.getDurationNano() << " nanoseconds\n";
Expand All @@ -133,6 +143,8 @@ class ScopeBenchmarker {
<< (static_cast<double>(cacheMisses) / cacheReferences) * 100
<< "%\n";
std::cout << "Instructions: " << instructions << "\n";
std::cout << "Minor Page Faults: " << minorPageFaults << "\n";
std::cout << "Major Page Faults: " << majorPageFaults << "\n";
}
};

Expand Down

0 comments on commit ab51f7b

Please sign in to comment.