Browse Source

added benchmark for neighbor closeness

fix-cli-restart
Kevin Froman 1 year ago
parent
commit
7dce969eaa
  1. 34
      tests/benchmarks/benchmark-neighbor-closeness.py

34
tests/benchmarks/benchmark-neighbor-closeness.py

@ -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…
Cancel
Save