This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from functools import wraps | ||
from time import time | ||
import sys | ||
|
||
def timing(f): | ||
@wraps(f) | ||
def wrap(*args, **kw): | ||
ts = time() | ||
result = f(*args, **kw) | ||
te = time() | ||
sys.stderr.write('func:%r args:[%r, %r] took: %2.4f sec\n' % \ | ||
(f.__name__, args, kw, te-ts)) | ||
return result | ||
return wrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from fastBloomFilter.bloom import * | ||
from fastBloomFilter.lib.timing import * | ||
|
||
bf0 = BloomFilter(array_size=128 * (1024 ** 2)) | ||
bf0.save("1.b") | ||
bf0.calc_hashid() | ||
bf0.stat() | ||
|
||
bf0.add("30000") | ||
bf0.add("1230213") | ||
bf0.add("1") | ||
|
||
bf1 = BloomFilter() | ||
bf1.calc_hashid() | ||
bf1.stat() | ||
|
||
bf1.load("1.b") | ||
bf1.calc_hashid() | ||
bf1.stat() | ||
|
||
assert bf1.update("1") == False | ||
assert bf1.update("2") == False | ||
assert bf1.query("1") | ||
|
||
@timing | ||
def test_timing_add(L=10**5): | ||
for i in range(0, L + 1): | ||
bf0.add(str(i)) | ||
|
||
@timing | ||
def test_timing_query(L=10**5): | ||
for i in range(0, L + 1): | ||
bf0.query(str(i)) | ||
|
||
test_timing_add() | ||
test_timing_query() |