Skip to content

Display time to execute when running SQL statements #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 25, 2025

Conversation

RobertNash1
Copy link
Contributor

#298

Resolved the ticket - added in performance metric (in milliseconds)

@julesyan julesyan requested a review from worksofliam March 18, 2025 22:31
@@ -112,7 +112,8 @@ export class ResultSetPanelProvider implements WebviewViewProvider {
columnHeadings: Configuration.get(`resultsets.columnHeadings`) || 'Name',
queryId: this.currentQuery.getId(),
update_count: queryResults.update_count,
isDone: queryResults.is_done
isDone: queryResults.is_done,
executionTime: (endTime - startTime).toFixed()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is being sent for every request (e.g. the first request and the following page requests).

We actually only care about the execution time of the execute call and not all of them.

You will have to add some code to only send the execution time for the first execute (perhaps you base it on getState()), and undefined for the following requests. The frontend will need to be updated to account for this.

@julesyan julesyan requested a review from worksofliam March 20, 2025 19:46
@janfh
Copy link
Contributor

janfh commented Mar 21, 2025

FYI: Execution time is added to the server response from mapepire. Probably it doesn't make any difference unless there is some network latency between vscode and the server. Execution time will be available when mapepire is bumped.

Mapepire-IBMi/mapepire-js#50

@worksofliam
Copy link
Contributor

@janfh you are correct, but this PR does do the frontend work which makes it viable still. Then another PR should come in and replace the backend logic with the data from Mapepire when it's been merged.

I am not ready to merge the Mapepire update yet. Still waiting on test feedback from some others.

Copy link
Contributor

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is really close! Just a small snag on some types and we should be good to go.

@@ -379,7 +379,12 @@ export function generateScroller(basicSelect: string, isCL: boolean, withCancel?
if (data.rows === undefined && totalRows === 0) {
document.getElementById(messageSpanId).innerText = 'Statement executed with no result set returned. Rows affected: ' + data.update_count;
} else {
document.getElementById(statusId).innerText = (noMoreRows ? ('Loaded ' + totalRows + '. End of data.') : ('Loaded ' + totalRows + '. More available.')) + ' ' + (updateTable ? 'Updatable.' : '');
if (data.executionTime > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the backend you're using toFixed() which returns a string, but here you're doing a numerical comparison. IMO, your backend code could send undefined on the second time around.

let executionTime: number|undefined;
if (this.currentQuery.getState() == "RUN_MORE_DATA_AVAILABLE") {
  queryResults = await this.currentQuery.fetchMore();
}
else {
  const startTime = performance.now();
  queryResults = await this.currentQuery.execute();
  const endTime = performance.now();
  executionTime = (endTime - startTime)
}

this._view.webview.postMessage({
  // ...
  executionTime //will send either a number or undefined
});

Then your frontend can do the toFixed calculation.

if (data.executionTime) {
  document.getElementById(statusId).innerText = (noMoreRows ? ('Loaded ' + totalRows + ' rows in ' + data.executionTime.toFixed() + 'ms. End of data.') : ('Loaded ' + totalRows + ' rows in ' + data.executionTime.toFixed() + 'ms. More available.')) + ' ' + (updateTable ? 'Updatable.' : '');
}

@julesyan julesyan requested a review from worksofliam March 24, 2025 14:11
Copy link
Contributor

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @RobertNash1

@worksofliam worksofliam merged commit 959df0b into codefori:main Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants