Commit 3cf19009 authored by Darko's avatar Darko

Change stats print places. Inc keys count.

parent 50b3672d
......@@ -5,7 +5,7 @@
#include "x.h"
#define MAXBUF 80
#define KEYCNT 10000
#define KEYCNT 1000000
int dodebug = 1;
......@@ -76,7 +76,6 @@ int main(int argc, char **argv)
key = random() % KEYCNT;
keys[i] = key;
res = sl_add(&sl, key, NULL);
sl_stat_print(&sl);
switch(res) {
case SL_ADD_NEW:
++cntnew;
......@@ -91,6 +90,7 @@ int main(int argc, char **argv)
}
printf("added %d new keys, %d same keys, list len: %lu\n",
cntnew, cntsame, sl.len);
sl_stat_print(&sl);
dodebug = 1;
sl_print(&sl);
dodebug = 0;
......@@ -98,20 +98,23 @@ int main(int argc, char **argv)
for (i = 0; i < KEYCNT; ++i) {
key = keys[i];
x = sl_find(&sl, key);
sl_stat_print(&sl);
if (!x) {
failed = 1;
break;
++cntnew;
} else {
++cntsame;
}
}
if (failed) {
fatal("find failed, report bug\n");
}
printf("should find %d keys but didn't, %d found keys, list len: %lu\n",
cntnew, cntsame, sl.len);
sl_stat_print(&sl);
cntnew = cntsame = 0;
for (i = 0; i < KEYCNT; ++i) {
key = keys[i];
res = sl_remove(&sl, key);
sl_stat_print(&sl);
switch (res) {
case 0:
++cntsame;
......@@ -132,6 +135,7 @@ int main(int argc, char **argv)
}
printf("removed %d keys, %d same keys, list len: %lu\n",
cntnew, cntsame, sl.len);
sl_stat_print(&sl);
sl_free(&sl);
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment