Skip to content

Instantly share code, notes, and snippets.

@DavidMStraub
Created November 11, 2020 18:30
Show Gist options
  • Save DavidMStraub/ea72c7a966d5ecf1ff4b14b418ec0feb to your computer and use it in GitHub Desktop.
Save DavidMStraub/ea72c7a966d5ecf1ff4b14b418ec0feb to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%load_ext snakeviz"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
".gramps.gen.utils.grampslocale.WARNING: ICU not loaded because No module named 'PyICU'. Localization will be impaired. Use your package manager to install PyICU\n"
]
}
],
"source": [
"import os\n",
"\n",
"from tests.test_endpoints import get_test_client\n",
"from tests import TEST_GRAMPSHOME, ExampleDbSQLite\n",
"\n",
"from gramps_webapi.const import ENV_CONFIG_FILE, TEST_EXAMPLE_GRAMPS_CONFIG\n",
"from gramps_webapi.app import create_app"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"os.environ[ENV_CONFIG_FILE] = TEST_EXAMPLE_GRAMPS_CONFIG"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Starte Import, Importiere Daten...\n",
"Import abgeschlossen...\n"
]
}
],
"source": [
"test_db = ExampleDbSQLite()\n",
"test_app = create_app(db_manager=test_db)\n",
"test_app.config[\"TESTING\"] = True\n",
"client = test_app.test_client()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"695 ms ± 86.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
"source": [
"%timeit client.get(\"/api/people/\")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"9.56 s ± 2.1 s per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
"source": [
"%timeit client.get(\"/api/people/?profile\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.45 s ± 23.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
"source": [
"%timeit client.get(\"/api/people/?profile\")"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n",
"*** Profile stats marshalled to file '/tmp/tmpn10n62nb'. \n",
"Embedding SnakeViz in this document...\n"
]
},
{
"data": {
"text/html": [
"\n",
"<iframe id='snakeviz-bc9778ba-23f4-11eb-9dc3-9bd9ad7788b5' frameborder=0 seamless width='100%' height='1000'></iframe>\n",
"<script>document.getElementById(\"snakeviz-bc9778ba-23f4-11eb-9dc3-9bd9ad7788b5\").setAttribute(\"src\", \"http://\" + document.location.hostname + \":8080/snakeviz/%2Ftmp%2Ftmpn10n62nb\")</script>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%snakeviz client.get(\"/api/people/?profile\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"66.7 ms ± 6.82 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
]
}
],
"source": [
"%timeit client.get(\"/api/people/GNUJQCL9MD64AM56OH\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"78.4 ms ± 5.35 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
]
}
],
"source": [
"%timeit client.get(\"/api/people/GNUJQCL9MD64AM56OH?profile\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment