chiark / gitweb /
speedtest: command-line control over repeats & maxiter
authorRichard Kettlewell <rjk@terraraq.org.uk>
Wed, 19 Dec 2012 21:43:51 +0000 (21:43 +0000)
committerRichard Kettlewell <rjk@terraraq.org.uk>
Wed, 19 Dec 2012 21:43:51 +0000 (21:43 +0000)
lib/speedtest.cc

index 720a625..8fa2ce1 100644 (file)
 #include "arith.h"
 #include <ctime>
 
-#define REPEATS 40000
-#define MAXITER 20000
-
-int main() {
+int main(int argc, char **argv) {
+  int repeats = 40000, maxiter = 20000;
+  if(argc > 1)
+    repeats = atoi(argv[1]);
+  if(argc > 2)
+    maxiter = atoi(argv[2]);
   for(int t = 0; t < arith_limit; ++t) {
     arith_t zx = 0;
     arith_t zy = 0;
     arith_t cx = 0.125;
     arith_t cy = 0.125;
     clock_t begin = clock();
-    for(int n = 0; n < REPEATS; ++n)
-      iterate(zx, zy, cx, cy, MAXITER, arith_type(t));
+    for(int n = 0; n < repeats; ++n)
+      iterate(zx, zy, cx, cy, maxiter, arith_type(t));
     clock_t end = clock();
     double seconds = (end - begin) / (double)CLOCKS_PER_SEC;
-    double iterations = (double)REPEATS * MAXITER;
+    double iterations = (double)repeats * maxiter;
     double ips = iterations / seconds;
     printf("%12s %6gs; %g iterations; %10g iterations/second\n", 
           arith_names[t], seconds, iterations, ips);