Correct hash rate calculation.
authorRoland Häder <haeder@hmmdeutschland.de>
Mon, 28 Apr 2014 09:07:17 +0000 (11:07 +0200)
committerRoland Häder <haeder@hmmdeutschland.de>
Mon, 28 Apr 2014 09:07:17 +0000 (11:07 +0200)
Signed-off-by: Roland Häder <haeder@hmmdeutschland.de>
contrib/chash/chash.php

index 6dc0eff3dc0002334bd72029155aef13ab4a445e..f4003c8a60087bc8234c44508a8d4d8a55259170 100644 (file)
@@ -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);