Skip to content

Commit a44f9ac

Browse files
committed
Improve performance of compare view using Promise.all
1 parent e1c03b0 commit a44f9ac

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

extensions/ql-vscode/src/compare/compare-view.ts

+18-16
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ export class CompareView extends AbstractWebview<
6666
to: CompletedLocalQueryInfo,
6767
selectedResultSetName?: string,
6868
) {
69-
const fromSchemas = await this.cliServer.bqrsInfo(
70-
from.completedQuery.query.resultsPaths.resultsPath,
71-
);
72-
const toSchemas = await this.cliServer.bqrsInfo(
73-
to.completedQuery.query.resultsPaths.resultsPath,
74-
);
69+
const [fromSchemas, toSchemas] = await Promise.all([
70+
this.cliServer.bqrsInfo(
71+
from.completedQuery.query.resultsPaths.resultsPath,
72+
),
73+
this.cliServer.bqrsInfo(to.completedQuery.query.resultsPaths.resultsPath),
74+
]);
7575

7676
const [fromSchemaNames, toSchemaNames] = await Promise.all([
7777
getResultSetNames(
@@ -293,16 +293,18 @@ export class CompareView extends AbstractWebview<
293293
fromResultSetName: string,
294294
toResultSetName: string,
295295
): Promise<RawQueryCompareResult> {
296-
const fromResultSet = await this.getResultSet(
297-
fromInfo.schemas,
298-
fromResultSetName,
299-
from.completedQuery.query.resultsPaths.resultsPath,
300-
);
301-
const toResultSet = await this.getResultSet(
302-
toInfo.schemas,
303-
toResultSetName,
304-
to.completedQuery.query.resultsPaths.resultsPath,
305-
);
296+
const [fromResultSet, toResultSet] = await Promise.all([
297+
this.getResultSet(
298+
fromInfo.schemas,
299+
fromResultSetName,
300+
from.completedQuery.query.resultsPaths.resultsPath,
301+
),
302+
this.getResultSet(
303+
toInfo.schemas,
304+
toResultSetName,
305+
to.completedQuery.query.resultsPaths.resultsPath,
306+
),
307+
]);
306308

307309
// Only compare columns that have the same name
308310
return resultsDiff(fromResultSet, toResultSet);

extensions/ql-vscode/src/compare/interpreted-results.ts

+15-17
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ export async function compareInterpretedResults(
2525
fromQuery: CompletedLocalQueryInfo,
2626
toQuery: CompletedLocalQueryInfo,
2727
): Promise<InterpretedQueryCompareResult> {
28-
const fromResultSet = await getInterpretedResults(
29-
fromQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
30-
);
31-
32-
const toResultSet = await getInterpretedResults(
33-
toQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
34-
);
35-
36-
if (!fromResultSet || !toResultSet) {
37-
throw new Error(
38-
"Could not find interpreted results for one or both queries.",
39-
);
40-
}
41-
4228
const database = databaseManager.findDatabaseItem(
4329
Uri.parse(toQuery.initialInfo.databaseInfo.databaseUri),
4430
);
@@ -48,9 +34,21 @@ export async function compareInterpretedResults(
4834
);
4935
}
5036

51-
const sourceLocationPrefix = await database.getSourceLocationPrefix(
52-
cliServer,
53-
);
37+
const [fromResultSet, toResultSet, sourceLocationPrefix] = await Promise.all([
38+
getInterpretedResults(
39+
fromQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
40+
),
41+
getInterpretedResults(
42+
toQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
43+
),
44+
database.getSourceLocationPrefix(cliServer),
45+
]);
46+
47+
if (!fromResultSet || !toResultSet) {
48+
throw new Error(
49+
"Could not find interpreted results for one or both queries.",
50+
);
51+
}
5452

5553
const fromResults = fromResultSet.runs[0].results;
5654
const toResults = toResultSet.runs[0].results;

0 commit comments

Comments
 (0)