Skip to content

Commit

Permalink
Anubhavgoel26/benchmarking (#50)
Browse files Browse the repository at this point in the history
* removed redundant benchmarking files

* added page faults to statistics

* fixing pre-commits
  • Loading branch information
anubhavgoel26 authored Apr 4, 2024
1 parent 05f73d4 commit 3c6ad7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 103 deletions.
102 changes: 0 additions & 102 deletions include/scea/perf.hpp

This file was deleted.

15 changes: 14 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,32 @@ 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 +144,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 3c6ad7e

Please sign in to comment.