Browse Source

show only total hashrate without debug

master
tcatm 14 years ago
parent
commit
47d05a7687
  1. 20
      miner.c

20
miner.c

@ -33,7 +33,7 @@
#define DEF_RPC_USERPASS "rpcuser:rpcpass" #define DEF_RPC_USERPASS "rpcuser:rpcpass"
enum { enum {
STAT_SLEEP_INTERVAL = 100, STAT_SLEEP_INTERVAL = 1,
STAT_CTR_INTERVAL = 10000000, STAT_CTR_INTERVAL = 10000000,
FAILURE_INTERVAL = 30, FAILURE_INTERVAL = 30,
}; };
@ -50,6 +50,7 @@ static char *userpass = DEF_RPC_USERPASS;
int block = 0; int block = 0;
double hashrates[16];
_clState *clStates[16]; _clState *clStates[16];
struct option_help { struct option_help {
@ -213,11 +214,19 @@ static void hashmeter(int thr_id, struct timeval *tv_start,
khashes = hashes_done / 1000.0; khashes = hashes_done / 1000.0;
secs = (double)diff.tv_sec + ((double)diff.tv_usec / 1000000.0); secs = (double)diff.tv_sec + ((double)diff.tv_usec / 1000000.0);
hashrates[thr_id] = khashes / secs;
if (opt_debug)
printf("HashMeter(%d): %lu hashes, %.2f khash/sec\n", printf("HashMeter(%d): %lu hashes, %.2f khash/sec\n",
thr_id, hashes_done, thr_id, hashes_done,
khashes / secs); khashes / secs);
} }
static void print_hashmeter(double hashrate) {
printf("HashMeter: %.2f Mhash/sec\n", hashrate / 1000);
}
static bool getwork(struct work_t *work) { static bool getwork(struct work_t *work) {
static const char *rpc_req = "{\"method\": \"getwork\", \"params\": [], \"id\":0}\r\n"; static const char *rpc_req = "{\"method\": \"getwork\", \"params\": [], \"id\":0}\r\n";
json_t *val; json_t *val;
@ -481,6 +490,8 @@ int main (int argc, char *argv[])
char name[32]; char name[32];
memset(hashrates, 0, sizeof(hashrates));
/* start mining threads */ /* start mining threads */
for (i = 0; i < nDevs; i++) { for (i = 0; i < nDevs; i++) {
pthread_t t; pthread_t t;
@ -503,7 +514,12 @@ int main (int argc, char *argv[])
/* main loop */ /* main loop */
while (program_running) { while (program_running) {
sleep(STAT_SLEEP_INTERVAL); sleep(STAT_SLEEP_INTERVAL);
/* do nothing */ double hashrate = 0;
for(i = 0; i < nDevs; i++)
hashrate += hashrates[i];
print_hashmeter(hashrate);
} }
return 0; return 0;

Loading…
Cancel
Save