From e3bc5de4e96efdac3e4310b725a5297c63678c45 Mon Sep 17 00:00:00 2001 From: Eduardo Blancas Date: Tue, 11 Jul 2023 21:39:33 -0600 Subject: [PATCH] fix benchmark --- benchmarks/duckdb.ipynb | 169 +--------------------------------------- 1 file changed, 4 insertions(+), 165 deletions(-) diff --git a/benchmarks/duckdb.ipynb b/benchmarks/duckdb.ipynb index b95840f5e..c668c7951 100644 --- a/benchmarks/duckdb.ipynb +++ b/benchmarks/duckdb.ipynb @@ -80,6 +80,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "892bc403-4f35-4489-889e-92eb76bda725", "metadata": { @@ -106,100 +107,6 @@ "%config SqlMagic.displaylimit = 1" ] }, - { - "cell_type": "code", - "execution_count": 4, - "id": "c7755eae-1943-4f57-9eb6-cf1354397bde", - "metadata": {}, - "outputs": [], - "source": [ - "# %timeit %sql select * from df" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "f1434280-93f5-4693-a106-67ac9ae03fab", - "metadata": {}, - "outputs": [], - "source": [ - "from sql.run import run\n", - "from sql.connection import Connection\n", - "from unittest.mock import Mock\n", - "\n", - "config = Mock()\n", - "config.autocommit = True\n", - "config.autolimit = 0" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "8d904cc9-975e-4475-bd52-b4cfa1a303a0", - "metadata": {}, - "outputs": [], - "source": [ - "from sql.magic import SqlMagic\n", - "from IPython import start_ipython, get_ipython\n", - "import duckdb\n", - "from pandas import DataFrame\n", - "import numpy as np\n", - "\n", - "num_rows = 1_000_000\n", - "\n", - "df = DataFrame(np.random.randn(num_rows, 20))\n", - "\n", - "magic = SqlMagic(get_ipython())\n", - "\n", - "conn = duckdb.connect()\n", - "# magic.execute(line=\"conn --alias duckdb\")\n", - "magic.execute(line=\"duckdb:// --alias duckdb\")\n", - "magic.autopandas = True\n", - "magic.displaycon = False\n", - "\n", - "\n", - "def run_magic():\n", - " return magic.execute(\"SELECT * FROM df\")" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "id": "ed06bc68-223a-4657-8dfe-4f07d6277b2c", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3.61 s ± 18.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" - ] - } - ], - "source": [ - "%%timeit\n", - "run_magic()" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "066fe987-cdd4-4b34-9203-cf58881f34e8", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "82.5 ms ± 1.38 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" - ] - } - ], - "source": [ - "%%timeit\n", - "run(Connection.current, \"SELECT * FROM df\", config)" - ] - }, { "cell_type": "code", "execution_count": 18, @@ -218,80 +125,11 @@ ], "source": [ "%%timeit\n", - "df_ = %sql select * from df\n", - "df_.DataFrame()" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "d1a0e680-6f2f-4ace-a388-dd14e59dba02", - "metadata": {}, - "outputs": [], - "source": [ - "%config SqlMagic.autopandas = False\n", - "df_ = %sql select * from df" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "2705fec6-27b8-44c0-bf2a-420b35138038", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "86.5 ms ± 1.81 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" - ] - } - ], - "source": [ - "%%timeit\n", - "df_.DataFrame()" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "af181428-4586-4c5c-bf01-10ed4be5cff6", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "85.7 ms ± 659 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" - ] - } - ], - "source": [ - "%%timeit\n", - "df_.sqlaproxy.execute(df_.statement)\n", - "df_.sqlaproxy.df()" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "9321e0a8-6f83-4dd4-abff-8dffe958e35b", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "87.1 ms ± 651 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n" - ] - } - ], - "source": [ - "%%timeit\n", - "df_.sqlaproxy.execute(df_.statement).df()" + "%sql select * from df" ] }, { + "attachments": {}, "cell_type": "markdown", "id": "1abcf8ab-0542-43fc-9cac-5ea9363e0827", "metadata": { @@ -331,6 +169,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "e7fb905f-4a13-4ee4-8150-30ee079e4ec4", "metadata": {