zeek/testing/btest/bifs/hll_large_estimate.zeek
Daniel Thayer 1a74516db1 Rename all BRO-prefixed environment variables
For backward compatibility when reading values, we first check
the ZEEK-prefixed value, and if not set, then check the corresponding
BRO-prefixed value.
2019-05-22 00:12:31 -05:00

26 lines
662 B
Text

#
# Test the quality of HLL once by checking adding a large number of IP entries.
#
# @TEST-EXEC: zeek -b %INPUT > out
# @TEST-EXEC: ZEEK_SEED_FILE="" zeek -b %INPUT > out2
# @TEST-EXEC: head -n1 out2 >> out
# @TEST-EXEC: btest-diff out
event zeek_init()
{
local cp: opaque of cardinality = hll_cardinality_init(0.1, 1.0);
local base: count = 2130706432; # 127.0.0.0
local i: count = 0;
while ( ++i < 170000 )
{
hll_cardinality_add(cp, count_to_v4_addr(base+i));
}
local res: int = double_to_count(hll_cardinality_estimate(cp));
if ( |res - 170000| > 17000 )
print "Big error";
else
print "Ok error";
print hll_cardinality_estimate(cp);
}