From: Roland Häder Date: Mon, 28 Apr 2014 09:07:17 +0000 (+0200) Subject: Correct hash rate calculation. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a0d5f5c2cdbd0adfc4be143d3c4f4a1f3798e679;p=core.git Correct hash rate calculation. Signed-off-by: Roland Häder --- diff --git a/contrib/chash/chash.php b/contrib/chash/chash.php index 6dc0eff3..f4003c8a 100644 --- a/contrib/chash/chash.php +++ b/contrib/chash/chash.php @@ -3,7 +3,7 @@ error_reporting(E_ALL | E_STRICT); define('HASH_ALGO', MHASH_RIPEMD320); define('BLOCK_SIZE', 1000); -define('NONCE_INCREMENT', 0.00001); +define('NONCE_INCREMENT', 0.0000000001); define('START_TIME', microtime(TRUE)); /** @@ -262,6 +262,7 @@ while (TRUE) { // Init counter $iter = 0; + $iterSecond = 0; // Now start the "mining" ... $timeHash = microtime(TRUE); @@ -280,7 +281,7 @@ while (TRUE) { $testTime = abs(microtime(TRUE) - $timeDisplay); // Calculate hashrate/sec - $hashrate = 1 / $testTime * $iter * 2 + 2; + $hashrate = 1 / $testTime * $iterSecond * 2; // Only every second if ($testTime >= 1) { @@ -289,10 +290,12 @@ while (TRUE) { // Reset timer $timeDisplay = microtime(TRUE); + $iterSecond = 0; } // END - if // Next round $iter++; + $iterSecond++; //print ('nonce=' . $nonce . ',iter=' . $iter . PHP_EOL); //print ('nonceHash=' . $nonceHash . PHP_EOL); //print ('sumNonce=' . $sumNonce . PHP_EOL);