added benchmark for neighbor closeness
This commit is contained in:
parent
79b46b62eb
commit
7dce969eaa
34
tests/benchmarks/benchmark-neighbor-closeness.py
Normal file
34
tests/benchmarks/benchmark-neighbor-closeness.py
Normal file
@ -0,0 +1,34 @@
|
||||
import sys, os
|
||||
sys.path.append(".")
|
||||
sys.path.append("src/")
|
||||
import unittest, uuid
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
||||
print("Test directory:", TEST_DIR)
|
||||
os.environ["ONIONR_HOME"] = TEST_DIR
|
||||
from utils import createdirs, identifyhome
|
||||
from streamfill import identify_neighbors
|
||||
|
||||
onions = []
|
||||
p = subprocess.Popen(["scripts/generate-onions.py", '50000'],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
for line in iter(p.stdout.readline, b''):
|
||||
line = line.decode()
|
||||
onions.append(line.strip())
|
||||
p.terminate()
|
||||
|
||||
p = subprocess.Popen(["scripts/generate-onions.py", '1'],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
for line in iter(p.stdout.readline, b''):
|
||||
us = line.decode().strip()
|
||||
p.terminate()
|
||||
|
||||
start = time.time()
|
||||
identify_neighbors(us, onions, 5)
|
||||
print(time.time() - start)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user