/* Simple speed tests for a hash of strings. */
#include <ccan/htable/htable_type.h>
#include <ccan/htable/htable.c>
/* Simple speed tests for a hash of strings. */
#include <ccan/htable/htable_type.h>
#include <ccan/htable/htable.c>
-#include <ccan/str_talloc/str_talloc.h>
-#include <ccan/grab_file/grab_file.h>
-#include <ccan/talloc/talloc.h>
+#include <ccan/tal/str/str.h>
+#include <ccan/tal/grab_file/grab_file.h>
+#include <ccan/tal/tal.h>
HTABLE_DEFINE_TYPE(char, strkey, hash_str, cmp, htable_str);
/* Nanoseconds per operation */
HTABLE_DEFINE_TYPE(char, strkey, hash_str, cmp, htable_str);
/* Nanoseconds per operation */
-static size_t normalize(const struct timeval *start,
- const struct timeval *stop,
+static size_t normalize(const struct timeabs *start,
+ const struct timeabs *stop,
- struct timeval diff;
-
- timersub(stop, start, &diff);
-
- /* Floating point is more accurate here. */
- return (double)(diff.tv_sec * 1000000 + diff.tv_usec)
- / num * 1000;
+ return time_to_nsec(time_divide(time_between(*stop, *start), num));
- words = strsplit(NULL, grab_file(NULL,
- argv[1] ? argv[1] : "/usr/share/dict/words",
- NULL), "\n");
+ words = tal_strsplit(NULL, grab_file(NULL,
+ argv[1] ? argv[1] : "/usr/share/dict/words"), "\n",
+ STR_NO_EMPTY);
/* Note that on my system, num is just > 98304, where we double! */
printf("%zu words\n", num);
/* Append and prepend last char for miss testing. */
/* Note that on my system, num is just > 98304, where we double! */
printf("%zu words\n", num);
/* Append and prepend last char for miss testing. */
- misswords[i] = talloc_asprintf(misswords, "%c%s%c%c",
- lastc, words[i], lastc, lastc);
+ misswords[i] = tal_fmt(misswords, "%c%s%c%c",
+ lastc, words[i], lastc, lastc);