From 04941b3cb8712cee9c3b0806cfe7aa76287c40e8 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sun, 24 Jul 2016 16:09:47 +0200 Subject: Updates to the local test suite - Adjust parameters to bring the running time of each test closer to 1 second - compression/arcode.c: array access one past - "inline" -> "static inline" - Remove cchecklink support --- test/c/qsort.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'test/c/qsort.c') diff --git a/test/c/qsort.c b/test/c/qsort.c index 802ef9ce..50b60be6 100644 --- a/test/c/qsort.c +++ b/test/c/qsort.c @@ -27,24 +27,24 @@ int cmpint(const void * i, const void * j) return 1; } +#define NITER 100 + int main(int argc, char ** argv) { - int n, i; + int n, i, j; int * a, * b; - int bench = 0; - if (argc >= 2) n = atoi(argv[1]); else n = 1000000; - if (argc >= 3) bench = 1; + if (argc >= 2) n = atoi(argv[1]); else n = 100000; a = malloc(n * sizeof(int)); b = malloc(n * sizeof(int)); - for (i = 0; i < n; i++) b[i] = a[i] = rand() & 0xFFFF; - quicksort(0, n - 1, a); - if (!bench) { - qsort(b, n, sizeof(int), cmpint); - for (i = 0; i < n; i++) { - if (a[i] != b[i]) { printf("Bug!\n"); return 2; } - } - printf("OK\n"); + for (j = 0; j < NITER; j++) { + for (i = 0; i < n; i++) b[i] = a[i] = rand() & 0xFFFF; + quicksort(0, n - 1, a); + } + qsort(b, n, sizeof(int), cmpint); + for (i = 0; i < n; i++) { + if (a[i] != b[i]) { printf("Bug!\n"); return 2; } } + printf("OK\n"); return 0; } -- cgit