]> git.sesse.net Git - stockfish/commitdiff
Guard against 'divide by zero' in bench
authorMarco Costalba <mcostalba@gmail.com>
Mon, 30 Jul 2012 07:44:54 +0000 (09:44 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 30 Jul 2012 17:05:15 +0000 (18:05 +0100)
Also remove an useless cast.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/benchmark.cpp

index b0b9e16b7881da1783326d72825a376998e99020..5800a37bb10484526c0aeb923d24c20bd2b0a0d8 100644 (file)
@@ -132,10 +132,10 @@ void benchmark(const Position& current, istream& is) {
       }
   }
 
-  int e = time.elapsed();
+  int e = time.elapsed() + 1; // Assure positive to avoid a 'divide by zero'
 
   cerr << "\n==========================="
        << "\nTotal time (ms) : " << e
        << "\nNodes searched  : " << nodes
-       << "\nNodes/second    : " << int(nodes / (e / 1000.0)) << endl;
+       << "\nNodes/second    : " << 1000 * nodes / e << endl;
 }