From b9ef0a5c9cb8661e75504ca83302e9f5129df1f2 Mon Sep 17 00:00:00 2001 From: Flavio Martins Date: Wed, 27 Mar 2024 15:46:54 +0000 Subject: [PATCH 01/12] Show the executions per second calculated from the last execution time. --- schema/settings.json | 6 ++++++ src/ExecuteTimeWidget.ts | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/schema/settings.json b/schema/settings.json index 675150f..1b26522 100644 --- a/schema/settings.json +++ b/schema/settings.json @@ -59,6 +59,12 @@ "description": "Show the formatted date string in the given format. For example \"yyy-MM-dd HH:mm:ss\" results in \"2023-02-28 14:25:57 \", \"dd/MM/YYY HH:mm:ss (O)\" results in \"28/02/2023 14:25:57 (GMT +3)\". Find out more on unicode date field symbols on this link [https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table]", "default": "yyy-MM-dd HH:mm:ss", "pattern": "[yGuqQMLwdeEcabBhHkKmsSzOxX\\W].*" + }, + "showExecutionsPerSecond": { + "type": "boolean", + "title": "Show Executions Per Second", + "description": "Show the executions per second calculated from the last execution time.", + "default": false } } } diff --git a/src/ExecuteTimeWidget.ts b/src/ExecuteTimeWidget.ts index 1d40d63..ea2be82 100644 --- a/src/ExecuteTimeWidget.ts +++ b/src/ExecuteTimeWidget.ts @@ -32,6 +32,7 @@ export interface IExecuteTimeSettings { showDate: boolean; historyCount: number; dateFormat: string; + showExecutionsPerSecond: boolean; } export default class ExecuteTimeWidget extends Widget { @@ -290,11 +291,13 @@ export default class ExecuteTimeWidget extends Widget { if (isLikelyAborted) { msg = ''; } else if (endTime) { - if ( - this._settings.minTime <= - differenceInMilliseconds(endTime, startTime) / 1000.0 - ) { + const executionTimeMillis = differenceInMilliseconds( + endTime, + startTime + ); + if (this._settings.minTime <= executionTimeMillis) { const executionTime = getTimeDiff(endTime, startTime); + const executionsPerSecond = 1000.0 / executionTimeMillis; const lastExecutionTime = executionTimeNode.getAttribute( PREV_DATA_EXECUTION_TIME_ATTR ); @@ -324,6 +327,9 @@ export default class ExecuteTimeWidget extends Widget { msg += ` at ${getTimeString(endTime, this._settings.dateFormat)}`; } msg += ` in ${executionTime}`; + if (this._settings.showExecutionsPerSecond) { + msg += ` (${executionsPerSecond.toFixed(2)} executions/s)`; + } } } else if (startTime) { if (this._settings.showLiveExecutionTime) { @@ -429,6 +435,10 @@ export default class ExecuteTimeWidget extends Widget { ); } + this._settings.showExecutionsPerSecond = settings.get( + 'showExecutionsPerSecond' + ).composite as boolean; + const cells = this._panel.context.model.cells; if (this._settings.enabled) { cells.changed.connect(this.updateConnectedCell); @@ -513,5 +523,6 @@ export default class ExecuteTimeWidget extends Widget { showDate: true, historyCount: 5, dateFormat: 'yyy-MM-dd HH:mm:ss', + showExecutionsPerSecond: false, }; } From 61a92408626808dbdc2d2abb53ffc9cd1d3cb3f7 Mon Sep 17 00:00:00 2001 From: Flavio Martins Date: Thu, 4 Apr 2024 11:29:20 +0100 Subject: [PATCH 02/12] Improve description using a more precise wording. --- schema/settings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema/settings.json b/schema/settings.json index 1b26522..4253fc0 100644 --- a/schema/settings.json +++ b/schema/settings.json @@ -62,8 +62,8 @@ }, "showExecutionsPerSecond": { "type": "boolean", - "title": "Show Executions Per Second", - "description": "Show the executions per second calculated from the last execution time.", + "title": "Show Cell Executions Per Second (executions/s)", + "description": "Show the cell executions per second calculated from the last cell execution time.", "default": false } } From cd6d9a374fd9de336201b2d04b8f112152530298 Mon Sep 17 00:00:00 2001 From: Flavio Martins Date: Thu, 11 Apr 2024 13:46:40 +0100 Subject: [PATCH 03/12] Now shows the number of cell outputs per second. --- schema/settings.json | 6 +++--- src/ExecuteTimeWidget.ts | 17 ++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/schema/settings.json b/schema/settings.json index 4253fc0..3c0f0d0 100644 --- a/schema/settings.json +++ b/schema/settings.json @@ -60,10 +60,10 @@ "default": "yyy-MM-dd HH:mm:ss", "pattern": "[yGuqQMLwdeEcabBhHkKmsSzOxX\\W].*" }, - "showExecutionsPerSecond": { + "showOutputsPerSecond": { "type": "boolean", - "title": "Show Cell Executions Per Second (executions/s)", - "description": "Show the cell executions per second calculated from the last cell execution time.", + "title": "Show Outputs Per Second (outputs/s)", + "description": "Show the outputs per second calculated from the last cell execution time and number of outputs.", "default": false } } diff --git a/src/ExecuteTimeWidget.ts b/src/ExecuteTimeWidget.ts index ea2be82..ceea3d8 100644 --- a/src/ExecuteTimeWidget.ts +++ b/src/ExecuteTimeWidget.ts @@ -32,7 +32,7 @@ export interface IExecuteTimeSettings { showDate: boolean; historyCount: number; dateFormat: string; - showExecutionsPerSecond: boolean; + showOutputsPerSecond: boolean; } export default class ExecuteTimeWidget extends Widget { @@ -327,8 +327,12 @@ export default class ExecuteTimeWidget extends Widget { msg += ` at ${getTimeString(endTime, this._settings.dateFormat)}`; } msg += ` in ${executionTime}`; - if (this._settings.showExecutionsPerSecond) { - msg += ` (${executionsPerSecond.toFixed(2)} executions/s)`; + + const numberOfOutputs = cell.model.outputs.length; + if (this._settings.showOutputsPerSecond && numberOfOutputs > 0) { + const outputsPerSecond = executionsPerSecond / numberOfOutputs; + msg += ` and generated ${numberOfOutputs} output(s)`; + msg += ` (${outputsPerSecond.toFixed(2)} outputs/s)`; } } } else if (startTime) { @@ -435,9 +439,8 @@ export default class ExecuteTimeWidget extends Widget { ); } - this._settings.showExecutionsPerSecond = settings.get( - 'showExecutionsPerSecond' - ).composite as boolean; + this._settings.showOutputsPerSecond = settings.get('showOutputsPerSecond') + .composite as boolean; const cells = this._panel.context.model.cells; if (this._settings.enabled) { @@ -523,6 +526,6 @@ export default class ExecuteTimeWidget extends Widget { showDate: true, historyCount: 5, dateFormat: 'yyy-MM-dd HH:mm:ss', - showExecutionsPerSecond: false, + showOutputsPerSecond: false, }; } From 69303e7f67d6a22cbfe3f810353dcf3afe787c6d Mon Sep 17 00:00:00 2001 From: Flavio Martins Date: Fri, 19 Apr 2024 16:12:15 +0100 Subject: [PATCH 04/12] Shorten the message displaying outputs/s --- src/ExecuteTimeWidget.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExecuteTimeWidget.ts b/src/ExecuteTimeWidget.ts index ceea3d8..62e99e4 100644 --- a/src/ExecuteTimeWidget.ts +++ b/src/ExecuteTimeWidget.ts @@ -331,7 +331,7 @@ export default class ExecuteTimeWidget extends Widget { const numberOfOutputs = cell.model.outputs.length; if (this._settings.showOutputsPerSecond && numberOfOutputs > 0) { const outputsPerSecond = executionsPerSecond / numberOfOutputs; - msg += ` and generated ${numberOfOutputs} output(s)`; + msg += ` displaying ${numberOfOutputs} output${numberOfOutputs === 1 ? '' : 's'}`; msg += ` (${outputsPerSecond.toFixed(2)} outputs/s)`; } } From cca94f0913d8da435e10595b7c720fcdc995a3b8 Mon Sep 17 00:00:00 2001 From: Flavio Martins Date: Fri, 19 Apr 2024 16:54:59 +0100 Subject: [PATCH 05/12] Further improve outputs per second message --- src/ExecuteTimeWidget.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ExecuteTimeWidget.ts b/src/ExecuteTimeWidget.ts index 62e99e4..94379a7 100644 --- a/src/ExecuteTimeWidget.ts +++ b/src/ExecuteTimeWidget.ts @@ -331,8 +331,10 @@ export default class ExecuteTimeWidget extends Widget { const numberOfOutputs = cell.model.outputs.length; if (this._settings.showOutputsPerSecond && numberOfOutputs > 0) { const outputsPerSecond = executionsPerSecond / numberOfOutputs; - msg += ` displaying ${numberOfOutputs} output${numberOfOutputs === 1 ? '' : 's'}`; - msg += ` (${outputsPerSecond.toFixed(2)} outputs/s)`; + msg += `, ${numberOfOutputs} output${ + numberOfOutputs === 1 ? '' : 's' + }`; + msg += ` at ${outputsPerSecond.toFixed(2)}/s`; } } } else if (startTime) { From 6b5bb0acdb2073f2ef4f7be11625855701485234 Mon Sep 17 00:00:00 2001 From: Flavio Martins Date: Sun, 21 Apr 2024 11:22:57 +0100 Subject: [PATCH 06/12] small fix to outputPerSecond option description --- schema/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/settings.json b/schema/settings.json index 3c0f0d0..0b514a1 100644 --- a/schema/settings.json +++ b/schema/settings.json @@ -62,7 +62,7 @@ }, "showOutputsPerSecond": { "type": "boolean", - "title": "Show Outputs Per Second (outputs/s)", + "title": "Show Outputs Per Second", "description": "Show the outputs per second calculated from the last cell execution time and number of outputs.", "default": false } From 771f5ac9e2b36dd9ba7d2244797c18e898dff020 Mon Sep 17 00:00:00 2001 From: Flavio Martins Date: Sun, 21 Apr 2024 11:43:34 +0100 Subject: [PATCH 07/12] add timing_outputs_outcomes.spec.ts for ui-tests --- .../notebooks/Timing_outputs_outcomes.ipynb | 102 ++++++++++++++++++ .../tests/timing_outputs_outcomes.spec.ts | 45 ++++++++ .../execution-started-linux.png | Bin 0 -> 2888 bytes .../last-executed-outputs-linux.png | Bin 0 -> 3639 bytes 4 files changed, 147 insertions(+) create mode 100644 ui-tests/notebooks/Timing_outputs_outcomes.ipynb create mode 100644 ui-tests/tests/timing_outputs_outcomes.spec.ts create mode 100644 ui-tests/tests/timing_outputs_outcomes.spec.ts-snapshots/execution-started-linux.png create mode 100644 ui-tests/tests/timing_outputs_outcomes.spec.ts-snapshots/last-executed-outputs-linux.png diff --git a/ui-tests/notebooks/Timing_outputs_outcomes.ipynb b/ui-tests/notebooks/Timing_outputs_outcomes.ipynb new file mode 100644 index 0000000..26eb85c --- /dev/null +++ b/ui-tests/notebooks/Timing_outputs_outcomes.ipynb @@ -0,0 +1,102 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "98ce2d4e-e422-40ea-aa89-5adabbb8d0f0", + "metadata": {}, + "source": [ + "Notes:\n", + "- Each cells is self-contained to allow parallel testing.\n", + "- Cells were collected in one notebook to reduce notebook upload overhead.\n", + "- Cell indices are used in tests." + ] + }, + { + "cell_type": "markdown", + "id": "4bf31c7c-ca89-421f-a617-4bba07d27054", + "metadata": {}, + "source": [ + "#### Execution started at (live progress, needs longer time):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2ab9d6c2-7963-490e-a1e9-f4190b099f47", + "metadata": {}, + "outputs": [], + "source": [ + "from time import sleep\n", + "sleep(5)" + ] + }, + { + "cell_type": "markdown", + "id": "f28cb5ea-94a4-47d3-9860-4cf20a29d690", + "metadata": {}, + "source": [ + "#### Last executed at:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3cfa2867-8f80-4793-9a4d-d773b06136e1", + "metadata": {}, + "outputs": [], + "source": [ + "for i in range(5):\n", + " display(1)\n", + " sleep(0.01)" + ] + }, + { + "cell_type": "markdown", + "id": "09793dea-c9f9-40f1-8353-bfc34ba16242", + "metadata": {}, + "source": [ + "#### Failed:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4d9d6725-090c-41df-8ca9-587af1f1bac7", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.system(f\"kill {os.getpid()}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1fe40632-72b4-4865-9fd2-498a73593d0b", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/ui-tests/tests/timing_outputs_outcomes.spec.ts b/ui-tests/tests/timing_outputs_outcomes.spec.ts new file mode 100644 index 0000000..a8f62ee --- /dev/null +++ b/ui-tests/tests/timing_outputs_outcomes.spec.ts @@ -0,0 +1,45 @@ +import { expect, galata, test } from '@jupyterlab/galata'; +import { openNotebook, cleanup, acceptDialog, maskedScreenshot } from './utils'; + +const SETTINGS_ID = 'jupyterlab-execute-time:settings'; + +test.describe('Timing outcomes', () => { + test.beforeEach(openNotebook('Timing_outputs_outcomes.ipynb')); + test.afterEach(cleanup); + // Disable flashing highlight for screenshot consistency + test.use({ + mockSettings: { + ...galata.DEFAULT_SETTINGS, + [SETTINGS_ID]: { + ...galata.DEFAULT_SETTINGS[SETTINGS_ID], + highlight: false, + showOutputsPerSecond: true, + }, + }, + }); + + test('"Execution started at" state', async ({ page }) => { + const cell = await page.notebook.getCell(2); + // Start executing cell but do not wait for it to complete + await cell.click(); + await page.keyboard.press('Control+Enter'); + + const widget = await cell.waitForSelector('.execute-time'); + expect(await widget.textContent()).toContain('Execution started at'); + expect(await maskedScreenshot(widget)).toMatchSnapshot( + 'execution-started-outputs.png' + ); + }); + + test('"Last executed at" state', async ({ page }) => { + const cell = await page.notebook.getCell(4); + + // Execute cell and wait for it to complete + await page.notebook.runCell(4); + + const widget = await cell.waitForSelector('.execute-time'); + expect(await widget.textContent()).toContain('Last executed at'); + expect(await widget.textContent()).toContain('outputs at'); + expect(await maskedScreenshot(widget)).toMatchSnapshot('last-executed-outputs.png'); + }); +}); diff --git a/ui-tests/tests/timing_outputs_outcomes.spec.ts-snapshots/execution-started-linux.png b/ui-tests/tests/timing_outputs_outcomes.spec.ts-snapshots/execution-started-linux.png new file mode 100644 index 0000000000000000000000000000000000000000..2757c4e46ddfcb59a8efa592a1b560377de3fa5f GIT binary patch literal 2888 zcmYk8cQl;q7RE=5PK4-!D5FFey+kHP3sJ@pB^Y6n;e;qhchra@dI=eIBRS1NhTu)2G%r9#*E65=AF@G1lL4xk{Jz)VCl$0DL=4mT} zsoOGI(UzM^&beU~yVygCn7!jZU?$^)qLWp*>CYmwneaNi?=vdqhKU$9Opwx{mraG{ zbJE^vYeSAvOOW6GO7-}`_}Exb_Q}Z!y7^@KpuYU1sSoDt>^v-VnTC=)Z1zoCX>+q3 zn_t)+fy*@4WP2}WE`i73Chb}{IX@@o3&a}%Vd3YAiI>qq2gD1UbaYJ2>h?B&t(2^6 z^4@Y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C2LSQ<^+U1%K|NIXa(LDeF literal 0 HcmV?d00001 From cb935d0ced995ee4b535ff416c5bc8cbd30c6bc2 Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Fri, 26 Apr 2024 12:51:28 +0100 Subject: [PATCH 08/12] Do not test execution started again, remove unused import and cells --- .../notebooks/Timing_outputs_outcomes.ipynb | 49 +----------------- .../tests/timing_outputs_outcomes.spec.ts | 23 +++----- .../execution-started-linux.png | Bin 2888 -> 0 bytes 3 files changed, 7 insertions(+), 65 deletions(-) delete mode 100644 ui-tests/tests/timing_outputs_outcomes.spec.ts-snapshots/execution-started-linux.png diff --git a/ui-tests/notebooks/Timing_outputs_outcomes.ipynb b/ui-tests/notebooks/Timing_outputs_outcomes.ipynb index 26eb85c..ac2ecd1 100644 --- a/ui-tests/notebooks/Timing_outputs_outcomes.ipynb +++ b/ui-tests/notebooks/Timing_outputs_outcomes.ipynb @@ -7,35 +7,15 @@ "source": [ "Notes:\n", "- Each cells is self-contained to allow parallel testing.\n", - "- Cells were collected in one notebook to reduce notebook upload overhead.\n", "- Cell indices are used in tests." ] }, - { - "cell_type": "markdown", - "id": "4bf31c7c-ca89-421f-a617-4bba07d27054", - "metadata": {}, - "source": [ - "#### Execution started at (live progress, needs longer time):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "2ab9d6c2-7963-490e-a1e9-f4190b099f47", - "metadata": {}, - "outputs": [], - "source": [ - "from time import sleep\n", - "sleep(5)" - ] - }, { "cell_type": "markdown", "id": "f28cb5ea-94a4-47d3-9860-4cf20a29d690", "metadata": {}, "source": [ - "#### Last executed at:" + "#### Last executed at with outputs:" ] }, { @@ -49,33 +29,6 @@ " display(1)\n", " sleep(0.01)" ] - }, - { - "cell_type": "markdown", - "id": "09793dea-c9f9-40f1-8353-bfc34ba16242", - "metadata": {}, - "source": [ - "#### Failed:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4d9d6725-090c-41df-8ca9-587af1f1bac7", - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "os.system(f\"kill {os.getpid()}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "1fe40632-72b4-4865-9fd2-498a73593d0b", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/ui-tests/tests/timing_outputs_outcomes.spec.ts b/ui-tests/tests/timing_outputs_outcomes.spec.ts index a8f62ee..3e90083 100644 --- a/ui-tests/tests/timing_outputs_outcomes.spec.ts +++ b/ui-tests/tests/timing_outputs_outcomes.spec.ts @@ -1,9 +1,9 @@ import { expect, galata, test } from '@jupyterlab/galata'; -import { openNotebook, cleanup, acceptDialog, maskedScreenshot } from './utils'; +import { openNotebook, cleanup, maskedScreenshot } from './utils'; const SETTINGS_ID = 'jupyterlab-execute-time:settings'; -test.describe('Timing outcomes', () => { +test.describe('Timing outcomes with ', () => { test.beforeEach(openNotebook('Timing_outputs_outcomes.ipynb')); test.afterEach(cleanup); // Disable flashing highlight for screenshot consistency @@ -18,21 +18,8 @@ test.describe('Timing outcomes', () => { }, }); - test('"Execution started at" state', async ({ page }) => { - const cell = await page.notebook.getCell(2); - // Start executing cell but do not wait for it to complete - await cell.click(); - await page.keyboard.press('Control+Enter'); - - const widget = await cell.waitForSelector('.execute-time'); - expect(await widget.textContent()).toContain('Execution started at'); - expect(await maskedScreenshot(widget)).toMatchSnapshot( - 'execution-started-outputs.png' - ); - }); - test('"Last executed at" state', async ({ page }) => { - const cell = await page.notebook.getCell(4); + const cell = await page.notebook.getCell(2); // Execute cell and wait for it to complete await page.notebook.runCell(4); @@ -40,6 +27,8 @@ test.describe('Timing outcomes', () => { const widget = await cell.waitForSelector('.execute-time'); expect(await widget.textContent()).toContain('Last executed at'); expect(await widget.textContent()).toContain('outputs at'); - expect(await maskedScreenshot(widget)).toMatchSnapshot('last-executed-outputs.png'); + expect(await maskedScreenshot(widget)).toMatchSnapshot( + 'last-executed-outputs.png' + ); }); }); diff --git a/ui-tests/tests/timing_outputs_outcomes.spec.ts-snapshots/execution-started-linux.png b/ui-tests/tests/timing_outputs_outcomes.spec.ts-snapshots/execution-started-linux.png deleted file mode 100644 index 2757c4e46ddfcb59a8efa592a1b560377de3fa5f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2888 zcmYk8cQl;q7RE=5PK4-!D5FFey+kHP3sJ@pB^Y6n;e;qhchra@dI=eIBRS1NhTu)2G%r9#*E65=AF@G1lL4xk{Jz)VCl$0DL=4mT} zsoOGI(UzM^&beU~yVygCn7!jZU?$^)qLWp*>CYmwneaNi?=vdqhKU$9Opwx{mraG{ zbJE^vYeSAvOOW6GO7-}`_}Exb_Q}Z!y7^@KpuYU1sSoDt>^v-VnTC=)Z1zoCX>+q3 zn_t)+fy*@4WP2}WE`i73Chb}{IX@@o3&a}%Vd3YAiI>qq2gD1UbaYJ2>h?B&t(2^6 z^4@Yk{Gsl@-$q7ud!(Dw3@VC?qgbIv-w%#@aMDF}bw~K1FNV+pQrmj-Ar=2!Vd>^mSxrsNQmg7q zH4mg}How=sTv&Ky#s7DuK^b&;>YINuCO5ddBOoz=ytO&$1SUF7k1;2K6?oynS@T^9 zruXlA8~->&czD2SU8lHfH_r}dmZP9}zm|B0;t!|h} z^MZr=UG=cpnJ;IYtlL!KzNE0QFg6a3y>F(*T!AZ-Zp|WUYMIH&R|<`?^$`eiWB8do z3nD+9`r#M1wi^$xEiL7FMuIm|`fr~wKy-C=>FDVz-@g|Y5D1-^ zc(Ad#d33y9G2R>k2ca=DGy5$_Q(3lu{{y-90iA6m2A~l*n84oSXy{ z6jBEUkjKZzNQu;Bw228zSy>s-3HI397C|2ukQnp$iMq;mVIOO#PTm_3nw1qN3iY~R zL$>wc6BC2{yXZv$HzCo$KJAfqMicVJK8CMqj6m+t(wT0bVB0z*iMR$M1NLM}Tz7o%;*10uRZ&E@W z8y_DW8Tq%U2+GdR&dUBvO^l6>iBI);OiWMOg0_xMa!QKu)n6cE=zvubpY7?m+FB*x z26+X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gX!OQdB}D-$3e;L>EY~9}*63$IY)`Ri zk(i`p`_Rx8diofcT7^ZaWf-bBzp(I91fq3~SYp)_sIs%O<1+S+3=}r7viho@hK5E8 z4#&#H6;)CqSyxvFNLA%Ldb6s!db}w}O*K1ycJ?9Y7@#)_0*&75BlZ}K+|vCPzus&$ z4mcd{fWdh9_;hx6|JCc**>j@hB+sp?s``aMpwfW~gK1)8qJ}=(NEeArlpl Date: Fri, 26 Apr 2024 12:52:03 +0100 Subject: [PATCH 09/12] Add changelog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d23639..42d11b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [3.2.0](https://github.com/deshaw/jupyterlab-execute-time/compare/v3.1.2...v3.2.0) (unreleased) + +### Added + +- Add an option to show the cell outputs per second [#116](https://github.com/deshaw/jupyterlab-execute-time/pull/116) + ## [3.1.2](https://github.com/deshaw/jupyterlab-execute-time/compare/v3.1.0...v3.1.2) (2024-02-14) ### Fixed From d553ca0db661dce3257656b168920bdb0213d90a Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:03:55 +0100 Subject: [PATCH 10/12] Adjust cell index after removing unused cells --- ui-tests/tests/timing_outputs_outcomes.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-tests/tests/timing_outputs_outcomes.spec.ts b/ui-tests/tests/timing_outputs_outcomes.spec.ts index 3e90083..7fea776 100644 --- a/ui-tests/tests/timing_outputs_outcomes.spec.ts +++ b/ui-tests/tests/timing_outputs_outcomes.spec.ts @@ -22,7 +22,7 @@ test.describe('Timing outcomes with ', () => { const cell = await page.notebook.getCell(2); // Execute cell and wait for it to complete - await page.notebook.runCell(4); + await page.notebook.runCell(2); const widget = await cell.waitForSelector('.execute-time'); expect(await widget.textContent()).toContain('Last executed at'); From 3927b85b3262f16ad7f2c29a5e8a78432f09aa29 Mon Sep 17 00:00:00 2001 From: Flavio Martins Date: Fri, 26 Apr 2024 18:11:34 +0100 Subject: [PATCH 11/12] fix comparison of millis with seconds --- src/ExecuteTimeWidget.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ExecuteTimeWidget.ts b/src/ExecuteTimeWidget.ts index 94379a7..439bc28 100644 --- a/src/ExecuteTimeWidget.ts +++ b/src/ExecuteTimeWidget.ts @@ -295,7 +295,7 @@ export default class ExecuteTimeWidget extends Widget { endTime, startTime ); - if (this._settings.minTime <= executionTimeMillis) { + if (this._settings.minTime <= executionTimeMillis / 1000.0) { const executionTime = getTimeDiff(endTime, startTime); const executionsPerSecond = 1000.0 / executionTimeMillis; const lastExecutionTime = executionTimeNode.getAttribute( From 5d845341f4730a7351a21c735ddfd2095756ae18 Mon Sep 17 00:00:00 2001 From: Flavio Martins Date: Fri, 26 Apr 2024 18:12:42 +0100 Subject: [PATCH 12/12] clarify in the description that showOutputsPerSecond option displays the metric after the cell is executed and not while the cell is running --- schema/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/settings.json b/schema/settings.json index 0b514a1..cf1a23b 100644 --- a/schema/settings.json +++ b/schema/settings.json @@ -63,7 +63,7 @@ "showOutputsPerSecond": { "type": "boolean", "title": "Show Outputs Per Second", - "description": "Show the outputs per second calculated from the last cell execution time and number of outputs.", + "description": "After a cell has finished running, show the outputs per second calculated from the last cell execution time and number of outputs.", "default": false } }