From a0d5f5c2cdbd0adfc4be143d3c4f4a1f3798e679 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 28 Apr 2014 11:07:17 +0200 Subject: [PATCH] Correct hash rate calculation. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- contrib/chash/chash.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); -- 2.39.5