test code modified
parent
c8024b10e0
commit
159d69983b
3
HISTORY
3
HISTORY
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
Version 1.24 2015-12-24
|
Version 1.24 2015-12-25
|
||||||
* php extension compiled on PHP 7
|
* php extension compiled on PHP 7
|
||||||
* add skiplist
|
* add skiplist
|
||||||
|
* make.sh: use sed to replace perl
|
||||||
|
|
||||||
Version 1.23 2015-11-16
|
Version 1.23 2015-11-16
|
||||||
* sched_thread.c: task can execute in a new thread
|
* sched_thread.c: task can execute in a new thread
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ typedef int (*skiplist_compare_func)(const void *p1, const void *p2);
|
||||||
typedef struct skiplist_node
|
typedef struct skiplist_node
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
|
// struct skiplist_node *prev; //for stable sort
|
||||||
struct skiplist_node *links[0];
|
struct skiplist_node *links[0];
|
||||||
} SkiplistNode;
|
} SkiplistNode;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ static int test_insert()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int result;
|
int result;
|
||||||
void *value;
|
|
||||||
int64_t start_time;
|
int64_t start_time;
|
||||||
int64_t end_time;
|
int64_t end_time;
|
||||||
|
void *value;
|
||||||
|
|
||||||
start_time = get_current_time_ms();
|
start_time = get_current_time_ms();
|
||||||
for (i=0; i<COUNT; i++) {
|
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);
|
printf("insert time used: %"PRId64" ms\n", end_time - start_time);
|
||||||
|
|
||||||
start_time = get_current_time_ms();
|
start_time = get_current_time_ms();
|
||||||
for (i=1; i<=COUNT; i++) {
|
for (i=0; i<COUNT; i++) {
|
||||||
value = skiplist_find(&sl, &i);
|
value = skiplist_find(&sl, numbers + i);
|
||||||
assert(value != NULL && *((int *)value) == i);
|
assert(value != NULL && *((int *)value) == numbers[i]);
|
||||||
}
|
}
|
||||||
end_time = get_current_time_ms();
|
end_time = get_current_time_ms();
|
||||||
printf("find time used: %"PRId64" ms\n", end_time - start_time);
|
printf("find time used: %"PRId64" ms\n", end_time - start_time);
|
||||||
|
|
@ -69,15 +69,15 @@ static void test_delete()
|
||||||
void *value;
|
void *value;
|
||||||
|
|
||||||
start_time = get_current_time_ms();
|
start_time = get_current_time_ms();
|
||||||
for (i=1; i<=COUNT; i++) {
|
for (i=0; i<COUNT; i++) {
|
||||||
assert(skiplist_delete(&sl, &i) == 0);
|
assert(skiplist_delete(&sl, numbers + i) == 0);
|
||||||
}
|
}
|
||||||
end_time = get_current_time_ms();
|
end_time = get_current_time_ms();
|
||||||
printf("delete time used: %"PRId64" ms\n", end_time - start_time);
|
printf("delete time used: %"PRId64" ms\n", end_time - start_time);
|
||||||
|
|
||||||
start_time = get_current_time_ms();
|
start_time = get_current_time_ms();
|
||||||
for (i=1; i<=COUNT; i++) {
|
for (i=0; i<COUNT; i++) {
|
||||||
value = skiplist_find(&sl, &i);
|
value = skiplist_find(&sl, numbers + i);
|
||||||
assert(value == NULL);
|
assert(value == NULL);
|
||||||
}
|
}
|
||||||
end_time = get_current_time_ms();
|
end_time = get_current_time_ms();
|
||||||
|
|
@ -123,12 +123,16 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
test_insert();
|
test_insert();
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
test_delete();
|
test_delete();
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
test_insert();
|
test_insert();
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
test_delete();
|
test_delete();
|
||||||
|
printf("\n");
|
||||||
skiplist_destroy(&sl);
|
skiplist_destroy(&sl);
|
||||||
|
|
||||||
printf("pass OK\n");
|
printf("pass OK\n");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue