Skip to content

Instantly share code, notes, and snippets.

@Roo4L
Created May 11, 2020 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Roo4L/fbe0b8ecc9ac296d7aee175095009c74 to your computer and use it in GitHub Desktop.
Save Roo4L/fbe0b8ecc9ac296d7aee175095009c74 to your computer and use it in GitHub Desktop.
#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