Finish renaming digestset_contains to digestset_probably_contains

Since bloom filters are probabilistic, it's nice to make it clear
that the "contains" operation can have false positives.
This commit is contained in:
Nick Mathewson
2018-06-26 13:20:54 -04:00
parent bf89278c79
commit ebbb0348dc
5 changed files with 14 additions and 14 deletions
+6 -4
View File
@@ -404,18 +404,20 @@ bench_dmap(void)
NANOCOUNT(pt3, pt4, iters*elts));
for (i = 0; i < iters; ++i) {
SMARTLIST_FOREACH(sl, const char *, cp, n += digestset_contains(ds, cp));
SMARTLIST_FOREACH(sl2, const char *, cp, n += digestset_contains(ds, cp));
SMARTLIST_FOREACH(sl, const char *, cp,
n += digestset_probably_contains(ds, cp));
SMARTLIST_FOREACH(sl2, const char *, cp,
n += digestset_probably_contains(ds, cp));
}
end = perftime();
printf("digestset_contains: %.2f ns per element.\n",
printf("digestset_probably_contains: %.2f ns per element.\n",
NANOCOUNT(pt4, end, iters*elts*2));
/* We need to use this, or else the whole loop gets optimized out. */
printf("Hits == %d\n", n);
for (i = 0; i < fpostests; ++i) {
crypto_rand(d, 20);
if (digestset_contains(ds, d)) ++fp;
if (digestset_probably_contains(ds, d)) ++fp;
}
printf("False positive rate on digestset: %.2f%%\n",
(fp/(double)fpostests)*100);
+3 -3
View File
@@ -644,18 +644,18 @@ test_container_digestset(void *arg)
}
set = digestset_new(1000);
SMARTLIST_FOREACH(included, const char *, cp,
if (digestset_contains(set, cp))
if (digestset_probably_contains(set, cp))
ok = 0);
tt_assert(ok);
SMARTLIST_FOREACH(included, const char *, cp,
digestset_add(set, cp));
SMARTLIST_FOREACH(included, const char *, cp,
if (!digestset_contains(set, cp))
if (!digestset_probably_contains(set, cp))
ok = 0);
tt_assert(ok);
for (i = 0; i < 1000; ++i) {
crypto_rand(d, DIGEST_LEN);
if (digestset_contains(set, d))
if (digestset_probably_contains(set, d))
++false_positives;
}
tt_int_op(50, OP_GT, false_positives); /* Should be far lower. */