Created
May 11, 2020 17:39
-
-
Save Roo4L/fbe0b8ecc9ac296d7aee175095009c74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include "main.h" | |
void timing(int list_len) { | |
TREE *tree; | |
tree = (TREE *)malloc(sizeof(TREE)); | |
tree->N = list_len; | |
tree->root = NULL; | |
int n = 10, key[100000][2], k[2], cnt = 500000, i, m; | |
char *info = "x"; | |
clock_t first, last; | |
srand(time(NULL)); | |
while (n-- > 0){ | |
m = 0; | |
for (i = 0; i < 1000; ++i) { | |
key[i][0] = i; | |
key[i][0] = i; | |
add_point(key[i], info, tree); | |
} | |
for (i = 1000; i < 100000; ++i) { | |
key[i][0] = rand(); | |
key[i][0] = rand(); | |
} | |
for (i = 1000; i < (10 - n)*cnt; ) { | |
k[0] = rand(); | |
k[1] = rand(); | |
if (add_point(k, info, tree)) | |
++i; | |
} | |
m = 0; | |
first = clock(); | |
for (i = 0; i < 100000; ++i) | |
if (find_point(key[i], tree)){ | |
++m; | |
} | |
last = clock(); | |
printf("%d items was found\n", m); | |
printf("test #%d, number of elements = %d, time = %ld\n", 10 - n, (10 -n)*cnt, last - first); | |
} | |
free_tree(tree); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment