-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
871c7fe
commit 459864b
Showing
12 changed files
with
1,970 additions
and
264 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,74 @@ | ||
#pragma once | ||
|
||
#include <iostream> | ||
#include <chrono> | ||
#include <ctime> | ||
|
||
namespace bench | ||
{ | ||
struct metrics_t | ||
{ | ||
double AccessCount, AccessRate, LoadBytes, LoadBandwidth, ArithmeticIntensity, Time; | ||
void print() | ||
{ | ||
std::cout | ||
<< "Time=" << Time << " " | ||
<< "AccessCount=" << AccessCount << " " | ||
<< "AccessRate=" << AccessRate << " " | ||
<< "ArithmeticIntensity=" << ArithmeticIntensity << " " | ||
<< "LoadBandwidth=" << LoadBandwidth << " " | ||
<< "LoadBytes=" << LoadBytes << "\n"; | ||
|
||
// 72M AccessRate=20.8765M/s ArithmeticIntensity=1.75 LoadBandwidth=250.519M/s LoadBytes=201.327M | ||
} | ||
}; | ||
|
||
struct chrono_t | ||
{ | ||
void Init() | ||
{ | ||
elapsed_ = 0; | ||
ResumeTiming(); | ||
} | ||
|
||
void PauseTiming() | ||
{ | ||
auto now = std::chrono::system_clock::now(); | ||
std::chrono::duration<double> e = now - last_point_; | ||
elapsed_ += e.count(); | ||
} | ||
|
||
void ResumeTiming() | ||
{ | ||
last_point_ = std::chrono::system_clock::now(); | ||
} | ||
|
||
double ElapsedTime() | ||
{ | ||
PauseTiming(); | ||
ResumeTiming(); | ||
return elapsed_; | ||
} | ||
|
||
std::size_t ElapsedTimeMS() | ||
{ | ||
PauseTiming(); | ||
ResumeTiming(); | ||
return elapsed_ * 1000; | ||
} | ||
|
||
std::string Str() | ||
{ | ||
// long t = static_cast<long>(elapsed_); | ||
// std::string res = | ||
// std::to_string(t) | ||
// + "." + std::to_string(elapsed_ - t); | ||
std::string res = std::to_string(elapsed_) + "s"; | ||
return res; | ||
} | ||
|
||
private: | ||
std::chrono::time_point<std::chrono::system_clock> last_point_; | ||
double elapsed_; | ||
}; | ||
} |
Oops, something went wrong.