From: Heng Li Date: Mon, 18 Apr 2011 02:06:31 +0000 (-0400) Subject: benchmark performance given unaligned memory X-Git-Tag: ksprintf-final~54 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/postgres_fdw.c?a=commitdiff_plain;h=d37245b761c212e33d28d31bb6443c7f4f824a11;p=klib.git benchmark performance given unaligned memory --- diff --git a/ksort_test.c b/ksort_test.c index f34f63a..92c7d3d 100644 --- a/ksort_test.c +++ b/ksort_test.c @@ -34,6 +34,21 @@ int main(int argc, char *argv[]) } } +#ifndef _ALIGNED_ONLY + { // test unaligned ksmall + srand48(11); + unsigned char *a; + int *b; + a = malloc(N * sizeof(int) + 1); + b = (int*)(a + 1); + for (i = 0; i < N; ++i) b[i] = (int)lrand48(); + t1 = clock(); + ks_introsort(int, N, b); + t2 = clock(); + fprintf(stderr, "introsort [%d]: %.3lf (unaligned: 0x%lx) \n", b[10500], (double)(t2-t1)/CLOCKS_PER_SEC, (size_t)b); + } +#endif + t1 = clock(); ks_introsort(int, N, array); t2 = clock();