NiceHash - benchmark mode

This commit is contained in:
fireice-uk
2017-02-08 19:50:17 +00:00
parent 2078969378
commit 426b1991a2
+48
View File
@@ -39,9 +39,12 @@ void win_exit()
void win_exit() { return; }
#endif // _WIN32
void do_benchmark();
int main(int argc, char *argv[])
{
const char* sFilename = "config.txt";
bool benchmark_mode = false;
if(argc >= 2)
{
@@ -53,7 +56,14 @@ int main(int argc, char *argv[])
}
if(argc >= 3 && strcasecmp(argv[1], "-c") == 0)
{
sFilename = argv[2];
}
else if(argc >= 3 && strcasecmp(argv[1], "benchmark_mode") == 0)
{
sFilename = argv[2];
benchmark_mode = true;
}
else
sFilename = argv[1];
}
@@ -70,6 +80,13 @@ int main(int argc, char *argv[])
return 0;
}
if(benchmark_mode)
{
do_benchmark();
win_exit();
return 0;
}
if(jconf::inst()->GetHttpdPort() != 0)
{
if (!httpd::inst()->start_daemon())
@@ -117,3 +134,34 @@ int main(int argc, char *argv[])
return 0;
}
void do_benchmark()
{
using namespace std::chrono;
std::vector<minethd*>* pvThreads;
printer::inst()->print_msg(L0, "Running a 60 second benchmark...");
uint8_t work[76] = {0};
minethd::miner_work oWork = minethd::miner_work("", work, sizeof(work), 0, 0, false, 0);
pvThreads = minethd::thread_starter(oWork);
uint64_t iStartStamp = time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
std::this_thread::sleep_for(std::chrono::seconds(60));
oWork = minethd::miner_work();
minethd::switch_work(oWork);
double fTotalHps = 0.0;
for (uint32_t i = 0; i < pvThreads->size(); i++)
{
double fHps = pvThreads->at(i)->iHashCount;
fHps /= (pvThreads->at(i)->iTimestamp - iStartStamp) / 1000.0d;
printer::inst()->print_msg(L0, "Thread %u: %.1f H/S", i, fHps);
fTotalHps += fHps;
}
printer::inst()->print_msg(L0, "Total: %.1f H/S", fTotalHps);
}