Created
April 17, 2018 03:07
-
-
Save gusutabopb/42550f0f07628ba61b0ed6322f02855b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from influxdb.line_protocol import make_lines\n", | |
"from aioinflux.serialization import make_line\n", | |
"from aioinflux.testing_utils import random_point" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"13.8 µs ± 672 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n", | |
"95.7 µs ± 3.52 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n" | |
] | |
} | |
], | |
"source": [ | |
"# taken from https://influxdb-python.readthedocs.io/en/latest/include-readme.html#examples\n", | |
"json_body = [\n", | |
" {\n", | |
" \"measurement\": \"cpu_load_short\",\n", | |
" \"tags\": {\n", | |
" \"host\": \"server01\",\n", | |
" \"region\": \"us-west\"\n", | |
" },\n", | |
" \"time\": \"2009-11-10T23:00:00Z\",\n", | |
" \"fields\": {\n", | |
" \"value\": 0.64\n", | |
" }\n", | |
" }\n", | |
"]\n", | |
"%timeit make_line(json_body[0])\n", | |
"%timeit make_lines({'points': json_body})" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"11.6 µs ± 205 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n", | |
"93.8 µs ± 1.87 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n" | |
] | |
} | |
], | |
"source": [ | |
"p = random_point()\n", | |
"%timeit make_line(p)\n", | |
"%timeit make_lines({'points': [p]})" | |
] | |
}, | |
{ | |
"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.6.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment