parent
9e073bdd3b
commit
f252284fa5
2 changed files with 17 additions and 12 deletions
|
|
@ -19,19 +19,21 @@ namespace vks
|
|||
class Benchmark {
|
||||
private:
|
||||
FILE *stream;
|
||||
VkPhysicalDeviceProperties deviceProps;
|
||||
public:
|
||||
bool active = false;
|
||||
bool outputFrameTimes = false;
|
||||
uint32_t warmup = 1;
|
||||
uint32_t duration = 10;
|
||||
std::vector<double> frameTimes;
|
||||
std::string filename = "benchmarkresults.csv";
|
||||
std::string filename = "";
|
||||
|
||||
double runtime = 0.0;
|
||||
uint32_t frameCount = 0;
|
||||
|
||||
void run(std::function<void()> renderFunc) {
|
||||
void run(std::function<void()> renderFunc, VkPhysicalDeviceProperties deviceProps) {
|
||||
active = true;
|
||||
this->deviceProps = deviceProps;
|
||||
#if defined(_WIN32)
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
freopen_s(&stream, "CONOUT$", "w+", stdout);
|
||||
|
|
@ -61,19 +63,20 @@ namespace vks
|
|||
frameCount++;
|
||||
};
|
||||
std::cout << "Benchmark finished" << std::endl;
|
||||
std::cout << "device : " << deviceProps.deviceName << " (driver version: " << deviceProps.driverVersion << ")" << std::endl;
|
||||
std::cout << "runtime: " << (runtime / 1000.0) << std::endl;
|
||||
std::cout << "frames: " << frameCount << std::endl;
|
||||
std::cout << "fps: " << frameCount / (runtime / 1000.0) << std::endl;
|
||||
std::cout << "frames : " << frameCount << std::endl;
|
||||
std::cout << "fps : " << frameCount / (runtime / 1000.0) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void saveResults(std::string appinfo, std::string deviceinfo) {
|
||||
void saveResults() {
|
||||
std::ofstream result(filename, std::ios::out);
|
||||
if (result.is_open()) {
|
||||
result << std::fixed << std::setprecision(4);
|
||||
|
||||
result << "duration (ms),frames,fps" << std::endl;
|
||||
result << runtime << "," << frameCount << "," << frameCount / (runtime / 1000.0) << std::endl;
|
||||
result << "device,driverversion,duration (ms),frames,fps" << std::endl;
|
||||
result << deviceProps.deviceName << "," << deviceProps.driverVersion << "," << runtime << "," << frameCount << "," << frameCount / (runtime / 1000.0) << std::endl;
|
||||
|
||||
if (outputFrameTimes) {
|
||||
result << std::endl << "frame,ms" << std::endl;
|
||||
|
|
@ -83,9 +86,9 @@ namespace vks
|
|||
double tMin = *std::min_element(frameTimes.begin(), frameTimes.end());
|
||||
double tMax = *std::max_element(frameTimes.begin(), frameTimes.end());
|
||||
double tAvg = std::accumulate(frameTimes.begin(), frameTimes.end(), 0.0) / (double)frameTimes.size();
|
||||
std::cout << "best : " << (1000.0 / tMin) << " fps (" << tMin << " ms)" << std::endl;
|
||||
std::cout << "worst: " << (1000.0 / tMax) << " fps (" << tMax << " ms)" << std::endl;
|
||||
std::cout << "avg : " << (1000.0 / tAvg) << " fps (" << tAvg << " ms)" << std::endl;
|
||||
std::cout << "best : " << (1000.0 / tMin) << " fps (" << tMin << " ms)" << std::endl;
|
||||
std::cout << "worst : " << (1000.0 / tMax) << " fps (" << tMax << " ms)" << std::endl;
|
||||
std::cout << "avg : " << (1000.0 / tAvg) << " fps (" << tAvg << " ms)" << std::endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue