diff options
-rw-r--r-- | bench/keymanager/Makefile | 37 | ||||
-rw-r--r-- | bench/keymanager/TODO | 1 | ||||
-rw-r--r-- | bench/keymanager/common.py | 266 | ||||
-rw-r--r-- | bench/keymanager/conftest.py | 73 | ||||
-rw-r--r-- | bench/keymanager/test_openpgp_speed.py | 308 | ||||
-rw-r--r-- | tests/integration/keymanager/common.py | 1 | ||||
-rw-r--r-- | tox.ini | 16 |
7 files changed, 702 insertions, 0 deletions
diff --git a/bench/keymanager/Makefile b/bench/keymanager/Makefile new file mode 100644 index 0000000..0a3db77 --- /dev/null +++ b/bench/keymanager/Makefile @@ -0,0 +1,37 @@ +# This makefile is currently intended to make it easy to generate the +# benchmarking graphs. + +RESULTS_FILE = tests/results.json +GRAPH_PREFIX = benchmark + +GRAPH_FILE = $(GRAPH_PREFIX)-test_gpg_init.svg + +all: $(GRAPH_FILE) + +# +# rules for generating one graph with the results of all speed tests +# + +$(RESULTS_FILE): + tox -v test_gpg_speed.py -- -v --pdb -s \ + --benchmark-max-time=2.0 \ + --benchmark-json=$(subst tests/,,$@) + +$(GRAPH_FILE): $(RESULTS_FILE) + py.test-benchmark compare $< --histogram $(GRAPH_PREFIX) + + +# +# rule for generating one graph for each graph +# + +test: + tox -v test_gpg_speed.py -- -v --pdb -s \ + --benchmark-histogram=gpg_speed \ + --benchmark-storage=./graphs/ \ + --benchmark-save=keymanager_gpg_speed \ + +clean: + rm -f $(RESULTS_FILE) $(GRAPH_PREFIX)*.svg + +.PHONY: all test graph diff --git a/bench/keymanager/TODO b/bench/keymanager/TODO new file mode 100644 index 0000000..9f596a1 --- /dev/null +++ b/bench/keymanager/TODO @@ -0,0 +1 @@ +- tune test params (max time, number of iterations, etc) diff --git a/bench/keymanager/common.py b/bench/keymanager/common.py new file mode 100644 index 0000000..6e906fa --- /dev/null +++ b/bench/keymanager/common.py @@ -0,0 +1,266 @@ +ADDRESS = 'leap@leap.se' +ADDRESS_2 = 'anotheruser@leap.se' + +KEY_FINGERPRINT = "E36E738D69173C13D709E44F2F455E2824D18DDF" + +CIPHERTEXT = """ +-----BEGIN PGP MESSAGE----- +Version: GnuPG v1 +hQIMAyj9aG/xtZOwAQ/+OtgYlCULNaCqSnzDIAIO5Swsg7fLFIErSWF/4ngkNxPk +GqL3/2/HvlLY6blsmn5RU2AK4vo5Dc5s2lQU3PwqsaVKNoqkn1G9bMqsoIQhP4vW +M6c+KdxtA8cQggENpx0kF8FXdvV+GclChfK38TDJUrJLnksfo+UP9rI2BsIpHpiS +sfikVLuUc83+2hTozuTOVARNG7x58hhnR7wPtbgm/6AwVNvU0SQDEDJXi43MFRbP +9VboUHIRZLbeIwlxFHj3umh4f8rca4jSwiWxDna2YRAFBZrFiyiGAnISZQc9Nh4d +jLqa7rMeLSfTigkOXVYdVjEgx/wsbsDjgJ2f6TUrfP6RWen3/4223ctfeL2x4r2V +6ej2cbbR61qQx2FR4HV4XRaSg3tV+Ytz0dklrvcL0PQVdSsJhDmRV4pNgLSt0/bA +E6F2hk/S3sjnXZRMvXNb3SRQk2R0Svn4j/8ft/8VC+h5jkHO2G5K3DbAHkS2MPJm +bLwx4LMPohZstS75OFKZv63nzdOYIz5gPSy9A4IC1VHqM4d3T99cqY8XOJOqRkr5 +TCYOxOHF4z6N2nRkzVXoDoTfC6+qx9bWuvGhoj5WjFG1I19e+L1IVVvpYKo6LAOa +7Dn+IXe3XnCGGHn3AusJgyeqt/3Z5HgzsSPMKIh2WfUKERZZ+vrxTXIf4Ko+2tbS +aQEpuiQUr9zE4z8eT+brGJNl5mx9c1qYCSPjGIGUCt8fTOKruMEkWBQHMln05qpF +nFMYk7JXtYaArGrC1QPRVHOvgUTB6Vx7KVHikzsEXGLF6ywBnZYzeh8ah/FtxHG9 +o+vTTcScQkxVcw== +=qYFS +-----END PGP MESSAGE----- +""" +SIGNEDTEXT = """ +-----BEGIN PGP MESSAGE----- +Version: GnuPG v1 +owHtwYszEwAcAOBtbMxrxOWRhp2aIq/Ligubt2Ynbh45c6Sb6mZbm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vunLGD0n9GOPMpji3UO3zeM8IYoWn7E +/EWK1XbjnssNemeeTZ+sDh+qrD7BOi+vCX1IyBxbfqnQfJZvmcPWpruy1UsO+aIC +0GY8Jr3OL69dDQ21jueJAh8EGAEIAAkFAlC9+dkCGwwACgkQL0VeKCTRjd9HCw/+ +LQSVgLLF4ulYlPCjWIIuQwrPbJfWUVVr2dPUFVM85DCv8gBzk5c121snXh9Swovm +laBbw6ate3BmbXLh64jVE9Za5sbTWi7PCcbO/bpRy4d6oLmitmNw6cq0vjTLxUYy +bwuiJxWREkfxuU85EKdouN062YDevH+/YResmlJrcCE7LRlJFeRlKsrrwBU3BqYd +GgFJjKjQC1peeQ9fj62Y7xfwE9+PXbkiWO5u/Bk8hb1VZH1SoIRU98NHVcp6BVvp +VK0jLAXuSauSczULmpRjbyt1lhaAqivDTWEEZXiNNbRyp17c3nVdPWOcgBr42hdQ +z25CgZgyLCsvu82wuXLKJblrIPJX3Yf+si6KqEWBsmwdOWybsjygaF5HvzgFqAAD +U0goPWoQ71PorP2XOUNp5ZLkBQp5etvtkksjVNMIhnHn8PGMuoxO39EUGlWj2B5l +Cu8tSosAzB1pS8NcLZzoNoI9dOHrmgJmP+GrOUkcf5GhNZbMoj4GNfGBRYX0SZlQ +GuDrwNKYj73C4MWyNnnUFyq8nDHJ/G1NpaF2hiof9RBL4PUU/f92JkceXPBXA8gL +Mz2ig1OButwPPLFGQhWqxXAGrsS3Ny+BhTJfnfIbbkaLLphBpDZm1D9XKbAUvdd1 +RZXoH+FTg9UAW87eqU610npOkT6cRaBxaMK/mDtGNdc= +=JTFu +-----END PGP PRIVATE KEY BLOCK----- +""" + +# key 7FEE575A: public key "anotheruser <anotheruser@leap.se>" +KEY_FINGERPRINT_2 = "F6E2B572ADB84EA58BD2E9A57F9DFA687FEE575A" +PUBLIC_KEY_2 = """ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.10 (GNU/Linux) + +mI0EUYwJXgEEAMbTKHuPJ5/Gk34l9Z06f+0WCXTDXdte1UBoDtZ1erAbudgC4MOR +gquKqoj3Hhw0/ILqJ88GcOJmKK/bEoIAuKaqlzDF7UAYpOsPZZYmtRfPC2pTCnXq +Z1vdeqLwTbUspqXflkCkFtfhGKMq5rH8GV5a3tXZkRWZhdNwhVXZagC3ABEBAAG0 +IWFub3RoZXJ1c2VyIDxhbm90aGVydXNlckBsZWFwLnNlPoi4BBMBAgAiBQJRjAle +AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRB/nfpof+5XWotuA/4tLN4E +gUr7IfLy2HkHAxzw7A4rqfMN92DIM9mZrDGaWRrOn3aVF7VU1UG7MDkHfPvp/cFw +ezoCw4s4IoHVc/pVlOkcHSyt4/Rfh248tYEJmFCJXGHpkK83VIKYJAithNccJ6Q4 +JE/o06Mtf4uh/cA1HUL4a4ceqUhtpLJULLeKo7iNBFGMCV4BBADsyQI7GR0wSAxz +VayLjuPzgT+bjbFeymIhjuxKIEwnIKwYkovztW+4bbOcQs785k3Lp6RzvigTpQQt +Z/hwcLOqZbZw8t/24+D+Pq9mMP2uUvCFFqLlVvA6D3vKSQ/XNN+YB919WQ04jh63 +yuRe94WenT1RJd6xU1aaUff4rKizuQARAQABiJ8EGAECAAkFAlGMCV4CGwwACgkQ +f536aH/uV1rPZQQAqCzRysOlu8ez7PuiBD4SebgRqWlxa1TF1ujzfLmuPivROZ2X +Kw5aQstxgGSjoB7tac49s0huh4X8XK+BtJBfU84JS8Jc2satlfwoyZ35LH6sDZck +I+RS/3we6zpMfHs3vvp9xgca6ZupQxivGtxlJs294TpJorx+mFFqbV17AzQ= +=Thdu +-----END PGP PUBLIC KEY BLOCK----- +""" + +PRIVATE_KEY_2 = """ +-----BEGIN PGP PRIVATE KEY BLOCK----- +Version: GnuPG v1.4.10 (GNU/Linux) + +lQHYBFGMCV4BBADG0yh7jyefxpN+JfWdOn/tFgl0w13bXtVAaA7WdXqwG7nYAuDD +kYKriqqI9x4cNPyC6ifP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ZL59mm5oigS00uIyR0SvusOr+UzTtd8ysRuwHy5d/LAZsbjQStaOMBILx +77TJveOel0a1QK0YSMF2ywZMCKvquvjli4hAtWYz/EwfuzQN3t23jc5ny+GqmqD2 +3FUxLJosFUfLNmECAO9KhVmJi+L9dswIs+2Dkjd1eiRQzNOEVffvYkGYZyKxNiXF +UA5kvyZcB4iAN9sWCybE4WHZ9jd4myGB0MPDGxkCAP1RsXJbbuD6zS7BXe5gwunO +2q4q7ptdSl/sJYQuTe1KNP5d/uGsvlcFfsYjpsopasPjFBIncc/2QThMKlhoEaEB +/0mVAxpT6SrEvUbJ18z7kna24SgMPr3OnPMxPGfvNLJY/Xv/A17YfoqjmByCvsKE +JCDjopXtmbcrZyoEZbEht9mko4ifBBgBAgAJBQJRjAleAhsMAAoJEH+d+mh/7lda +z2UEAKgs0crDpbvHs+z7ogQ+Enm4EalpcWtUxdbo83y5rj4r0TmdlysOWkLLcYBk +o6Ae7WnOPbNIboeF/FyvgbSQX1POCUvCXNrGrZX8KMmd+Sx+rA2XJCPkUv98Hus6 +THx7N776fcYHGumbqUMYrxrcZSbNveE6SaK8fphRam1dewM0 +=a5gs +-----END PGP PRIVATE KEY BLOCK----- +""" diff --git a/bench/keymanager/conftest.py b/bench/keymanager/conftest.py new file mode 100644 index 0000000..b7d8b50 --- /dev/null +++ b/bench/keymanager/conftest.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +# conftest.py +# Copyright (C) 2016 LEAP Encryption Acess Project +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +""" +Fixtures for the benchmarks for leap.bitmask.keymanager +""" + +import pytest + +from leap.bitmask.keymanager.keys import build_key_from_dict +from leap.bitmask.keymanager.wrapper import TempGPGWrapper + +from common import ADDRESS +from common import KEY_FINGERPRINT +from common import PUBLIC_KEY +from common import PRIVATE_KEY +from common import ADDRESS_2 +from common import KEY_FINGERPRINT_2 +from common import PUBLIC_KEY_2 +from common import PRIVATE_KEY_2 + + +@pytest.fixture +def wrapper(keys=None): + return TempGPGWrapper(keys=keys) + + +def _get_key(address, key_fingerprint, key_data, private): + kdict = { + 'uids': [address], + 'fingerprint': key_fingerprint, + 'key_data': key_data, + 'private': private, + 'length': 4096, + 'expiry_date': 0, + 'refreshed_at': 1311239602, + } + key = build_key_from_dict(kdict) + return key + + +@pytest.fixture +def public_key(): + return _get_key(ADDRESS, KEY_FINGERPRINT, PUBLIC_KEY, False) + + +@pytest.fixture +def public_key_2(): + return _get_key(ADDRESS_2, KEY_FINGERPRINT_2, PUBLIC_KEY_2, False) + + +@pytest.fixture +def openpgp_keys(): + return [ + _get_key(ADDRESS, KEY_FINGERPRINT, PUBLIC_KEY, False), + _get_key(ADDRESS_2, KEY_FINGERPRINT_2, PUBLIC_KEY_2, False), + _get_key(ADDRESS, KEY_FINGERPRINT, PRIVATE_KEY, True), + _get_key(ADDRESS_2, KEY_FINGERPRINT_2, PRIVATE_KEY_2, True), + ] diff --git a/bench/keymanager/test_openpgp_speed.py b/bench/keymanager/test_openpgp_speed.py new file mode 100644 index 0000000..e3368f6 --- /dev/null +++ b/bench/keymanager/test_openpgp_speed.py @@ -0,0 +1,308 @@ +# -*- coding: utf-8 -*- +# test_opengpg_speed.py +# Copyright (C) 2016 LEAP Encryption Acess Project +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +""" +Benchmarking for the leap.bitmask.keymanager.openpgp module +""" + +import commands +import pytest + +from functools import partial + +from gnupg import GPG +from leap.bitmask.keymanager.wrapper import TempGPGWrapper + +from common import CIPHERTEXT +from common import SIGNEDTEXT + + +GROUP_INIT = 'initialization only' +GROUP_CRYPTO = 'crypto only' +GROUP_INIT_AND_CRYPTO = 'initialization and crypto' + + +# the gnupg module gets the binary version each time the GPG object is +# initialized. In some platforms this takes hundreds of milliseconds, and +# sometimes more than a second. This is currently a known bug. For making it +# evident, we provide a way to bypass the version check by monkeypatching the +# actual function that does the job. + +def get_gpg_version(): + output = commands.getoutput( + 'gpg --list-config --with-colons | grep version') + version = output.split(':').pop() + return version + + +GPG_VERSION = get_gpg_version() + + +def mock_gpg_get_version(monkeypatch): + def _setver(self): + self.binary_version = GPG_VERSION + monkeypatch.setattr( + GPG, '_check_sane_and_get_gpg_version', _setver) + + +# +# generic speed test creator +# + +def create_test(fun, num_keys=0, mock_get_version=True, init=None, group=None): + + @pytest.mark.benchmark(group=group) + def test(tmpdir, benchmark, openpgp_keys, monkeypatch): + + if mock_get_version: + mock_gpg_get_version(monkeypatch) + + if init: + res = init(tmpdir, benchmark, openpgp_keys, monkeypatch, num_keys) + benchmark(fun, res) + else: + benchmark( + fun, tmpdir, benchmark, openpgp_keys, monkeypatch, num_keys) + + return test + + +# +# gpg initializarion: 0, 1 and 2 keys +# + +def gpg_init_only(tmpdir, benchmark, openpgp_keys, monkeypatch, num_keys): + keys = openpgp_keys[0:num_keys] + gpg = GPG(homedir=tmpdir.dirname) + for key in keys: + gpg.import_keys(key.key_data) + + +test_gpg_init_nokey_slow = create_test( + gpg_init_only, num_keys=0, + mock_get_version=False, + group=GROUP_INIT) +test_gpg_init_1key_slow = create_test( + gpg_init_only, num_keys=1, + mock_get_version=False, + group=GROUP_INIT) +test_gpg_init_2keys_slow = create_test( + gpg_init_only, num_keys=2, + mock_get_version=False, + group=GROUP_INIT) + +test_gpg_init_nokey = create_test( + gpg_init_only, num_keys=0, + group=GROUP_INIT) +test_gpg_init_1key = create_test( + gpg_init_only, num_keys=1, + group=GROUP_INIT) +test_gpg_init_2keys = create_test( + gpg_init_only, num_keys=2, + group=GROUP_INIT) + + +# +# wrapper initialization: 0, 1 and 2 keys +# + +def wrapper_init_only(tmpdir, benchmark, openpgp_keys, monkeypatch, num_keys): + keys = openpgp_keys[0:num_keys] + wrapper = TempGPGWrapper(keys=keys) + with wrapper as gpg: + assert GPG == type(gpg) + + +test_wrapper_init_nokey_slow = create_test( + wrapper_init_only, num_keys=0, + mock_get_version=False, + group=GROUP_INIT) +test_wrapper_init_1key_slow = create_test( + wrapper_init_only, num_keys=1, + mock_get_version=False, + group=GROUP_INIT) +test_wrapper_init_2keys_slow = create_test( + wrapper_init_only, num_keys=2, + mock_get_version=False, + group=GROUP_INIT) + +test_wrapper_init_nokey = create_test( + wrapper_init_only, num_keys=0, + group=GROUP_INIT) +test_wrapper_init_1key = create_test( + wrapper_init_only, num_keys=1, + group=GROUP_INIT) +test_wrapper_init_2keys = create_test( + wrapper_init_only, num_keys=2, + group=GROUP_INIT) + + +# +# initialization + encryption +# + +PLAINTEXT = ' ' * 10000 # 10 KB + + +def gpg_init_exec(fun, tmpdir, benchmark, openpgp_keys, monkeypatch, _): + pubkey = openpgp_keys[0] + privkey = openpgp_keys[2] # this is PRIVATE_KEY + gpg = GPG(homedir=tmpdir.dirname) + gpg.import_keys(pubkey.key_data) + gpg.import_keys(privkey.key_data) + fun((gpg, pubkey, privkey)) + + +def wrapper_init_exec(fun, tmpdir, benchmark, openpgp_keys, monkeypatch, _): + pubkey = openpgp_keys[0] + privkey = openpgp_keys[2] + wrapper = TempGPGWrapper(keys=[pubkey, privkey]) + wrapper._build_keyring() + fun((wrapper._gpg, pubkey, privkey)) + + +def gpg_enc(res): + gpg, pubkey, _ = res + ciphertext = gpg.encrypt(PLAINTEXT, pubkey.fingerprint) + assert ciphertext.ok + assert len(ciphertext.data) + + +test_gpg_init_enc = create_test( + partial(gpg_init_exec, gpg_enc), + group=GROUP_INIT_AND_CRYPTO) +test_wrapper_init_enc = create_test( + partial(wrapper_init_exec, gpg_enc), + group=GROUP_INIT_AND_CRYPTO) + + +# +# initialization + decryption +# + +def gpg_dec(res): + gpg, _, _ = res + plaintext = gpg.decrypt(CIPHERTEXT) + assert plaintext.ok + assert len(plaintext.data) + + +test_gpg_init_dec = create_test( + partial(gpg_init_exec, gpg_dec), + group=GROUP_INIT_AND_CRYPTO) +test_wrapper_init_dec = create_test( + partial(wrapper_init_exec, gpg_dec), + group=GROUP_INIT_AND_CRYPTO) + + +# +# initialization + sign +# + +def gpg_sign(res): + gpg, _, privkey = res + gpg.import_keys(privkey.key_data) + signed = gpg.sign(PLAINTEXT, default_key=privkey.fingerprint) + assert signed.status == 'begin signing' + assert len(signed.data) > len(PLAINTEXT) + assert '-----BEGIN PGP SIGNATURE-----' in signed.data + assert '-----END PGP SIGNATURE-----' in signed.data + + +test_gpg_init_sign = create_test( + partial(gpg_init_exec, gpg_sign), + group=GROUP_INIT_AND_CRYPTO) +test_wrapper_init_sign = create_test( + partial(wrapper_init_exec, gpg_sign), + group=GROUP_INIT_AND_CRYPTO) + + +# +# initialization + verify +# + +def gpg_verify(res): + gpg, _, privkey = res + signed = gpg.verify(SIGNEDTEXT) + assert signed.valid + + +test_gpg_init_verify = create_test( + partial(gpg_init_exec, gpg_verify), + group=GROUP_INIT_AND_CRYPTO) +test_wrapper_init_verify = create_test( + partial(wrapper_init_exec, gpg_verify), + group=GROUP_INIT_AND_CRYPTO) + + +# +# encryption only +# + +def gpg_init(tmpdir, benchmark, openpgp_keys, monkeypatch, _): + pubkey = openpgp_keys[0] + privkey = openpgp_keys[2] # this is PRIVATE_KEY + gpg = GPG(homedir=tmpdir.dirname) + gpg.import_keys(pubkey.key_data) + gpg.import_keys(privkey.key_data) + return gpg, pubkey, privkey + + +def wrapper_init(tmpdir, benchmark, openpgp_keys, monkeypatch, _): + pubkey = openpgp_keys[0] + privkey = openpgp_keys[2] + wrapper = TempGPGWrapper(keys=[pubkey, privkey]) + wrapper._build_keyring() + return wrapper._gpg, pubkey, privkey + + +test_gpg_enc = create_test( + gpg_enc, init=gpg_init, group=GROUP_CRYPTO) +test_wrapper_enc = create_test( + gpg_enc, init=wrapper_init, group=GROUP_CRYPTO) + + +# +# decryption only +# + +test_gpg_dec = create_test( + gpg_dec, + init=gpg_init, group=GROUP_CRYPTO) +test_wrapper_dec = create_test( + gpg_dec, + init=wrapper_init, group=GROUP_CRYPTO) + + +# +# sign only +# + +test_gpg_sign = create_test( + gpg_sign, init=gpg_init, group=GROUP_CRYPTO) +test_wrapper_sign = create_test( + gpg_sign, init=wrapper_init, group=GROUP_CRYPTO) + + +# +# verify only +# + +test_gpg_verify = create_test( + gpg_verify, init=gpg_init, group=GROUP_CRYPTO) +test_wrapper_verify = create_test( + gpg_verify, init=wrapper_init, group=GROUP_CRYPTO) diff --git a/tests/integration/keymanager/common.py b/tests/integration/keymanager/common.py index fb8b4ef..e170d78 100644 --- a/tests/integration/keymanager/common.py +++ b/tests/integration/keymanager/common.py @@ -266,6 +266,7 @@ RZXoH+FTg9UAW87eqU610npOkT6cRaBxaMK/mDtGNdc= """ # key 7FEE575A: public key "anotheruser <anotheruser@leap.se>" +KEY_FINGERPRINT_2 = "F6E2B572ADB84EA58BD2E9A57F9DFA687FEE575A" PUBLIC_KEY_2 = """ -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.4.10 (GNU/Linux) @@ -34,3 +34,19 @@ deps = -e../soledad/common -e../soledad/client -e. + +[testenv:py27-bench] +commands = py.test {posargs} +changedir = bench +deps = + gnupg + pytest + pytest-benchmark + # need the next 2 for graphs, but new version changed api a bit and is + # incompatible with pytest-benchmark, so we pin version <2.1 + # (https://github.com/ionelmc/pytest-benchmark/issues/50). + pygal<2.1 + pygaljs +setenv = + HOME=/tmp + TERM=xterm |