summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2017-09-18 09:57:42 -0300
committerdrebs <drebs@riseup.net>2017-09-20 18:55:59 -0300
commitdac9c79e1c3adaa118794f92b29f97d009478589 (patch)
tree236fc18a36631fcdbe5f5eccbc9730145cd62f63
parent2ee61596f334c3358cbc825ab11d36b6488cd376 (diff)
[test] remove dependency on numpy
-rw-r--r--tests/benchmarks/conftest.py24
-rw-r--r--tox.ini22
2 files changed, 20 insertions, 26 deletions
diff --git a/tests/benchmarks/conftest.py b/tests/benchmarks/conftest.py
index 80eccb08..2755ee48 100644
--- a/tests/benchmarks/conftest.py
+++ b/tests/benchmarks/conftest.py
@@ -1,5 +1,4 @@
import functools
-import numpy
import os
import psutil
import pytest
@@ -70,6 +69,18 @@ def txbenchmark_with_setup(monitored_benchmark_with_setup):
# resource monitoring
#
+def _mean(l):
+ return float(sum(l)) / len(l)
+
+
+def _std(l):
+ if len(l) <= 1:
+ return 0
+ mean = _mean(l)
+ squares = [(x - mean) ** 2 for x in l]
+ return (sum(squares) / (len(l) - 1)) ** 0.5
+
+
class ResourceWatcher(threading.Thread):
sampling_interval = 0.1
@@ -102,14 +113,17 @@ class ResourceWatcher(threading.Thread):
self.cpu_percent = self.process.cpu_percent()
# save memory usage info
if self.watch_memory:
+ stats = {
+ 'max': max(self.memory_samples),
+ 'min': min(self.memory_samples),
+ 'mean': _mean(self.memory_samples),
+ 'std': _std(self.memory_samples),
+ }
memory_percent = {
'sampling_interval': self.sampling_interval,
'samples': self.memory_samples,
- 'stats': {},
+ 'stats': stats,
}
- for stat in 'max', 'min', 'mean', 'std':
- fun = getattr(numpy, stat)
- memory_percent['stats'][stat] = fun(self.memory_samples)
self.memory_percent = memory_percent
diff --git a/tox.ini b/tox.ini
index f78db2fe..19004f97 100644
--- a/tox.ini
+++ b/tox.ini
@@ -26,7 +26,6 @@ deps =
leap.common
# used by benchmarks
psutil
- numpy
pytest-benchmark
elasticsearch
certifi
@@ -54,26 +53,7 @@ commands =
--cov=leap.soledad \
{posargs}
usedevelop = True
-deps =
- coverage
- pytest
- pytest-cov
- pytest-twisted
- mock
- testscenarios
- setuptools-trial
- couchdb
- requests
- service_identity
-# used by benchmarks
- psutil
- numpy
- pytest-benchmark
- elasticsearch
- certifi
-# install soledad local packages
- -e.[client]
- -e.[server]
+deps = {[testenv]deps}
setenv =
HOME=/tmp
TERM=xterm