test code modified

pull/5/head
yuqing 2015-12-25 16:56:52 +08:00
parent c8024b10e0
commit 159d69983b
3 changed files with 15 additions and 9 deletions

View File

@ -1,7 +1,8 @@
Version 1.24 2015-12-24
Version 1.24 2015-12-25
* php extension compiled on PHP 7
* add skiplist
* make.sh: use sed to replace perl
Version 1.23 2015-11-16
* sched_thread.c: task can execute in a new thread

View File

@ -21,6 +21,7 @@ typedef int (*skiplist_compare_func)(const void *p1, const void *p2);
typedef struct skiplist_node
{
void *data;
// struct skiplist_node *prev; //for stable sort
struct skiplist_node *links[0];
} SkiplistNode;

View File

@ -26,9 +26,9 @@ static int test_insert()
{
int i;
int result;
void *value;
int64_t start_time;
int64_t end_time;
void *value;
start_time = get_current_time_ms();
for (i=0; i<COUNT; i++) {
@ -40,9 +40,9 @@ static int test_insert()
printf("insert time used: %"PRId64" ms\n", end_time - start_time);
start_time = get_current_time_ms();
for (i=1; i<=COUNT; i++) {
value = skiplist_find(&sl, &i);
assert(value != NULL && *((int *)value) == i);
for (i=0; i<COUNT; i++) {
value = skiplist_find(&sl, numbers + i);
assert(value != NULL && *((int *)value) == numbers[i]);
}
end_time = get_current_time_ms();
printf("find time used: %"PRId64" ms\n", end_time - start_time);
@ -69,15 +69,15 @@ static void test_delete()
void *value;
start_time = get_current_time_ms();
for (i=1; i<=COUNT; i++) {
assert(skiplist_delete(&sl, &i) == 0);
for (i=0; i<COUNT; i++) {
assert(skiplist_delete(&sl, numbers + i) == 0);
}
end_time = get_current_time_ms();
printf("delete time used: %"PRId64" ms\n", end_time - start_time);
start_time = get_current_time_ms();
for (i=1; i<=COUNT; i++) {
value = skiplist_find(&sl, &i);
for (i=0; i<COUNT; i++) {
value = skiplist_find(&sl, numbers + i);
assert(value == NULL);
}
end_time = get_current_time_ms();
@ -123,12 +123,16 @@ int main(int argc, char *argv[])
}
test_insert();
printf("\n");
test_delete();
printf("\n");
test_insert();
printf("\n");
test_delete();
printf("\n");
skiplist_destroy(&sl);
printf("pass OK\n");