Add bench for sort functions.
This commit is contained in:
1 parent
2a5829bb23
commit
d67cc326b7
6 files changed
+105
-1
No files matched your search
@@ -11,6 +11,7 @@
|
||||
#include "klist.h"
|
||||
#include "kbtree.h"
|
||||
#include "khash.h"
|
||||
#include "ksort.h"
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
@@ -197,6 +198,27 @@ test_dict_big(unsigned long n)
|
||||
kh_destroy(iub, dict);
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
// NOTE: Needed for compiling
|
||||
static double drand48(void) { return rand_get(); }
|
||||
|
||||
KSORT_INIT_GENERIC(float)
|
||||
|
||||
static void test_sort(size_t n)
|
||||
{
|
||||
rand_init();
|
||||
kvec_t(float) a1;
|
||||
|
||||
kv_init(a1);
|
||||
for(size_t i = 0; i < n; i++) {
|
||||
kv_push(float, a1, rand_get() );
|
||||
}
|
||||
// NOTE: Is-it the right way to do? Seems very low level!
|
||||
ks_introsort_float(n, & kv_A(a1, 0));
|
||||
g_result = kv_A(a1, 0);
|
||||
kv_destroy(a1);
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
@@ -212,5 +234,7 @@ int main(int argc, const char *argv[])
|
||||
test_function("Dict time", 1000000, test_dict);
|
||||
if (n == 6)
|
||||
test_function("DictB time", 1000000, test_dict_big);
|
||||
if (n == 7)
|
||||
test_function("Sort time", 10000000, test_sort);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user