Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Feb 14, 2020
1 parent 88b48c0 commit f9364aa
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tests/app/performance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,30 @@


def get_cell(seconds):
cell = ', { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "time.sleep(' + str(seconds) + ')\\n", "t1 = time.time()\\n", "log += str(t1 - t0) + \'\\\\n\'\\n", "t0 = t1" ] }'
cell = ', { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], '
'"source": [ "time.sleep(' + str(seconds) + ')\\n", "t1 = time.time()\\n", "log += '
'str(t1 - t0) + \'\\\\n\'\\n", "t0 = t1" ] }'
return cell


def get_ipynb(cell_nb, sleep_per_cell, result_dir):
ipynb = '{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import uuid\\n", "import time\\n", "fname = str(uuid.uuid4()) + \'.log\'\\n", "log = \'\'\\n", "t0 = time.time()" ] }'
ipynb = '{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs"'
': [], "source": [ "import uuid\\n", "import time\\n", "fname = str(uuid.uuid4()) + \''
'.log\'\\n", "log = \'\'\\n", "t0 = time.time()" ] }'
for i in range(cell_nb):
cell = get_cell(sleep_per_cell)
ipynb += cell
ipynb += ', { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with open(\'' + result_dir + '/\' + fname, \'w\') as f:\\n", " f.write(log)" ] }'
ipynb += ' ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.1" } }, "nbformat": 4, "nbformat_minor": 4 }'
ipynb += ', { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], '
'"source": [ "with open(\'' + result_dir + '/\' + fname, \'w\') as f:\\n", " '
'f.write(log)" ] }'
ipynb += ' ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", '
'"name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", '
'"version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python"'
', "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.1" } }'
', "nbformat": 4, "nbformat_minor": 4 }'
return ipynb


def test_performance():
sleep_per_cell = 0.1 # each cell sleeps for that amount of seconds
cell_nb = 100 # each notebook consists of so many cells
Expand Down Expand Up @@ -52,13 +64,13 @@ def test_performance():
i = 0
exec_time = cell_nb * sleep_per_cell # notebook execution time
launch_time = client_nb * 0.5 # kernel takes about 0.5s to launch
min_time = launch_time + exec_time # theoretical time for all notebooks to execute
# min_time = launch_time + exec_time # theoretical time for all notebooks to execute
timeout_time = launch_time + 2 * exec_time # timeout allows slow machines to finish
while not done:
time.sleep(1)
done = True
i += 1
#print(i, '/', min_time)
# print(i, '/', min_time)
for client in clients:
if client.poll() is None:
done = False
Expand Down

0 comments on commit f9364aa

Please sign in to comment.