Skip to content

Commit 1f7256a

Browse files
Add timings to regression3
1 parent 5ec618f commit 1f7256a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
_Static_assert(CHAR_BIT == 8, "Buffers passed to fmemopen presume 8 bit chars");
2020

21+
static const double secondsPerWU = 0.5 / 1000. / 1000.;
2122
static int successes = 0;
2223
static int failures = 0;
2324

@@ -516,13 +517,20 @@ static void regression_tests(void) {
516517
/* word("2^23 zero bits") ; unit */
517518
size_t sizeof_regression3 = ((size_t)1 << 20) + 4;
518519
unsigned char *regression3 = calloc(sizeof_regression3, 1);
520+
clock_t start, end;
521+
double diff, bound;
519522
const uint32_t cmr[] = {
520523
0x7f81c076u, 0xf0df9505u, 0xbfce61f0u, 0x41197bd9u, 0x2aaaa4f1u, 0x7015d1ecu, 0xb248ddffu, 0xe9d9da07u
521524
};
522525
assert(regression3);
523526
regression3[0] = 0xb7; regression3[1] = 0x08;
524527
regression3[sizeof_regression3 - 2] = 0x48; regression3[sizeof_regression3 - 1] = 0x20;
528+
start = clock();
525529
test_program("regression3", regression3, sizeof_regression3, SIMPLICITY_ERR_EXEC_MEMORY, cmr, NULL, NULL, NULL);
530+
end = clock();
531+
diff = (double)(end - start) / CLOCKS_PER_SEC;
532+
bound = (double)(sizeof_regression3) * secondsPerWU;
533+
printf("cpu_time_used by regression3: %f s. (Should be less than %f s.)\n", diff, bound);
526534
free(regression3);
527535
}
528536
}
@@ -531,7 +539,6 @@ static void iden8mebi_test(void) {
531539
/* iden composed with itself 2^23 times. */
532540
const unsigned char iden8mebi[23] = {0xe1, 0x08};
533541
const ubounded expectedCost = 1677721500; /* in milliWU */
534-
const double secondsPerWU = 0.5 / 1000. / 1000.;
535542
clock_t start, end;
536543
double diff, bound;
537544
start = clock();

0 commit comments

Comments
 (0)