--- attic/digest-timing.c.orig 2018-06-11 21:36:09.000000000 -0700
+++ attic/digest-timing.c 2018-06-19 23:14:59.000000000 -0700
#include <openssl/rand.h>
#include <openssl/objects.h>
+#include "ntp_machine.h" /* For clock_gettime fallback */
#define UNUSED_ARG(arg) ((void)(arg))
#define EVP_MD_CTX_reset(ctx) EVP_MD_CTX_init(ctx)
+ * Pecking order for clock_gettime interval measurements
+ * CLOCK_MONOTONIC_RAW is free of NTP adjustments
+ * CLOCK_MONOTONIC is affected by NTP slewing but not step adjustments
+ * CLOCK_REALTIME is affected by all NTP adjustments, including stepping
+ * Assuming this test isn't run while stepping is a possibility,
+ * even CLOCK_REALTIME is acceptable.
+#if defined(CLOCK_MONOTONIC_RAW)
+#define CLOCK_INTERVAL CLOCK_MONOTONIC_RAW
+#elif defined(CLOCK_MONOTONIC)
+#define CLOCK_INTERVAL CLOCK_MONOTONIC
+#define CLOCK_INTERVAL CLOCK_REALTIME
/* Get timing for old slower way too. Pre Feb 2018 */
if (NULL == digest) return;
- clock_gettime(CLOCK_MONOTONIC, &start);
+ clock_gettime(CLOCK_INTERVAL, &start);
for (i = 0; i < NUM; i++) {
digestlength = SSL_Digest(digest, key, keylength, pkt, pktlength);
- clock_gettime(CLOCK_MONOTONIC, &stop);
+ clock_gettime(CLOCK_INTERVAL, &stop);
fast = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
printf("%10s %2d %2d %2u %6.0f %6.3f",
name, keylength, pktlength, digestlength, fast/NUM, fast/1E9);
- clock_gettime(CLOCK_MONOTONIC, &start);
+ clock_gettime(CLOCK_INTERVAL, &start);
for (i = 0; i < NUM; i++) {
digestlength = SSL_DigestSlow(type, key, keylength, pkt, pktlength);
- clock_gettime(CLOCK_MONOTONIC, &stop);
+ clock_gettime(CLOCK_INTERVAL, &stop);
slow = (stop.tv_sec-start.tv_sec)*1E9 + (stop.tv_nsec-start.tv_nsec);
printf(" %6.0f %2.0f %4.0f",
slow/NUM, (slow-fast)*100.0/slow, (slow-fast)/NUM);