The timeout should be based on a monotonic clock.

The wrapper function for the app_timer_* interfaces obfuscates
things, so delete it.

totalTimer should be set, not added to: the code doesn't
increment it every iteration.

ok?

P.S. huh, there's an FPE if nConn == 0.

Index: s_time.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/s_time.c,v
retrieving revision 1.28
diff -u -p -r1.28 s_time.c
--- s_time.c    21 Aug 2018 15:56:39 -0000      1.28
+++ s_time.c    21 Aug 2018 16:22:52 -0000
@@ -227,18 +227,6 @@ s_time_usage(void)
 }
 
 /***********************************************************************
- * TIME - time functions
- */
-#define START  TM_RESET
-#define STOP   TM_GET
-
-static double
-tm_Time_F(int op)
-{
-       return app_timer_user(op);
-}
-
-/***********************************************************************
  * MAIN - main processing area for client
  *                     real name depends on MONOLITH
  */
@@ -407,10 +395,9 @@ run_test(SSL *scon)
 static int
 benchmark(int reuse_session)
 {
-       double totalTime = 0.0;
+       double elapsed, totalTime;
        int nConn = 0;
        SSL *scon = NULL;
-       time_t finishtime;
        int ret = 1;
        int ver;
 
@@ -426,15 +413,13 @@ benchmark(int reuse_session)
        }
 
        nConn = 0;
-       totalTime = 0.0;
-
-       finishtime = time(NULL) + s_time_config.maxtime;
-
        bytes_read = 0;
-       tm_Time_F(START);
 
+       app_timer_real(TM_RESET);
+       app_timer_user(TM_RESET);
        for (;;) {
-               if (finishtime < time(NULL))
+               elapsed = app_timer_real(TM_GET);
+               if (elapsed > s_time_config.maxtime)
                        break;
                if (scon == NULL) {
                        if ((scon = SSL_new(tm_ctx)) == NULL)
@@ -464,13 +449,13 @@ benchmark(int reuse_session)
                        scon = NULL;
                }
        }
-       totalTime += tm_Time_F(STOP);   /* Add the time for this iteration */
+       totalTime = app_timer_user(TM_GET);
 
        printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes 
read %ld\n",
            nConn, totalTime, ((double) nConn / totalTime), bytes_read);
-       printf("%d connections in %lld real seconds, %ld bytes read per 
connection\n",
+       printf("%d connections in %.0f real seconds, %ld bytes read per 
connection\n",
            nConn,
-           (long long)(time(NULL) - finishtime + s_time_config.maxtime),
+           elapsed,
            bytes_read / nConn);
 
        ret = 0;

Reply via email to