summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcheloha <>2018-08-22 20:36:24 +0000
committercheloha <>2018-08-22 20:36:24 +0000
commitf8934d14f52bfac2b569919ddfa210b7cfd8180a (patch)
tree15eb6fecacf64b74b47748d4e95868be068f102c /src
parent0efe9a67702e1062521567f7091216b2696777ff (diff)
downloadopenbsd-f8934d14f52bfac2b569919ddfa210b7cfd8180a.tar.gz
openbsd-f8934d14f52bfac2b569919ddfa210b7cfd8180a.tar.bz2
openbsd-f8934d14f52bfac2b569919ddfa210b7cfd8180a.zip
Use a monotonic clock for the benchmark timeout.
While here, we don't need the app_timer_* wrapper function, it only obfuscates things, so delete it. Also while here, totalTime only needs to be assigned once. ok tb@
Diffstat (limited to 'src')
-rw-r--r--src/usr.bin/openssl/s_time.c33
1 files changed, 9 insertions, 24 deletions
diff --git a/src/usr.bin/openssl/s_time.c b/src/usr.bin/openssl/s_time.c
index 8aa3d9fbea..906d36228f 100644
--- a/src/usr.bin/openssl/s_time.c
+++ b/src/usr.bin/openssl/s_time.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_time.c,v 1.28 2018/08/21 15:56:39 cheloha Exp $ */ 1/* $OpenBSD: s_time.c,v 1.29 2018/08/22 20:36:24 cheloha Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -227,18 +227,6 @@ s_time_usage(void)
227} 227}
228 228
229/*********************************************************************** 229/***********************************************************************
230 * TIME - time functions
231 */
232#define START TM_RESET
233#define STOP TM_GET
234
235static double
236tm_Time_F(int op)
237{
238 return app_timer_user(op);
239}
240
241/***********************************************************************
242 * MAIN - main processing area for client 230 * MAIN - main processing area for client
243 * real name depends on MONOLITH 231 * real name depends on MONOLITH
244 */ 232 */
@@ -407,10 +395,9 @@ run_test(SSL *scon)
407static int 395static int
408benchmark(int reuse_session) 396benchmark(int reuse_session)
409{ 397{
410 double totalTime = 0.0; 398 double elapsed, totalTime;
411 int nConn = 0; 399 int nConn = 0;
412 SSL *scon = NULL; 400 SSL *scon = NULL;
413 time_t finishtime;
414 int ret = 1; 401 int ret = 1;
415 int ver; 402 int ver;
416 403
@@ -426,15 +413,13 @@ benchmark(int reuse_session)
426 } 413 }
427 414
428 nConn = 0; 415 nConn = 0;
429 totalTime = 0.0;
430
431 finishtime = time(NULL) + s_time_config.maxtime;
432
433 bytes_read = 0; 416 bytes_read = 0;
434 tm_Time_F(START);
435 417
418 app_timer_real(TM_RESET);
419 app_timer_user(TM_RESET);
436 for (;;) { 420 for (;;) {
437 if (finishtime < time(NULL)) 421 elapsed = app_timer_real(TM_GET);
422 if (elapsed > s_time_config.maxtime)
438 break; 423 break;
439 if (scon == NULL) { 424 if (scon == NULL) {
440 if ((scon = SSL_new(tm_ctx)) == NULL) 425 if ((scon = SSL_new(tm_ctx)) == NULL)
@@ -464,13 +449,13 @@ benchmark(int reuse_session)
464 scon = NULL; 449 scon = NULL;
465 } 450 }
466 } 451 }
467 totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ 452 totalTime = app_timer_user(TM_GET);
468 453
469 printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", 454 printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n",
470 nConn, totalTime, ((double) nConn / totalTime), bytes_read); 455 nConn, totalTime, ((double) nConn / totalTime), bytes_read);
471 printf("%d connections in %lld real seconds, %ld bytes read per connection\n", 456 printf("%d connections in %.0f real seconds, %ld bytes read per connection\n",
472 nConn, 457 nConn,
473 (long long)(time(NULL) - finishtime + s_time_config.maxtime), 458 elapsed,
474 bytes_read / nConn); 459 bytes_read / nConn);
475 460
476 ret = 0; 461 ret = 0;