#include #include #include #include int less(void* a, void* b) { int ai, bi; ai = *(int*)a; bi = *(int*)b; return ai - bi; } int test·sort() { clock_t t; int i, test[10000]; for(i = 0; i < arrlen(test); i++) test[i] = rng·randi(1000000); t = clock(); sort·int(test, arrlen(test)); t = clock() - t; fmt·print("inlined code took %f ms to execute\n", 1000.*t/CLOCKS_PER_SEC); for (i = 0; i < arrlen(test); i++) test[i] = rng·randi(1000000); t = clock(); /* qsort(test, arrlen(test), sizeof(int), (int (*)(const void *, const void *))less); */ t = clock() - t; fmt·print("std qsort code took %f ms to execute\n", 1000.*t/CLOCKS_PER_SEC); /* for (i = 1; i < arrlen(test); i++) { if (test[i] >= test[i-1]) { printf("%d is less that %d\n", test[i], test[i-1]); } else { printf("ERROR: %d is NOT less that %d\n", test[i], test[i-1]); } } */ return 0; } int main() { int err; #if 0 if (err = test·coro(), err) { errorf("test fail: coroutine"); } #endif if (err = test·sort(), err) { errorf("test fail: coroutine"); } return 0; }