Skip to content
This repository has been archived by the owner on Oct 21, 2019. It is now read-only.

Commit

Permalink
NiceHash - benchmark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fireice-uk committed Feb 8, 2017
1 parent 2078969 commit 426b199
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cli-miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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];
}
Expand All @@ -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())
Expand Down Expand Up @@ -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);
}

0 comments on commit 426b199

Please sign in to comment.