Improve performance of compare view using Promise.all

This commit is contained in:
Koen Vlaswinkel
2023-12-06 14:59:36 +01:00
parent ab1966abf1
commit d4a4536d40
2 changed files with 33 additions and 33 deletions

View File

@@ -68,12 +68,12 @@ export class CompareView extends AbstractWebview<
to: CompletedLocalQueryInfo,
selectedResultSetName?: string,
) {
const fromSchemas = await this.cliServer.bqrsInfo(
from.completedQuery.query.resultsPaths.resultsPath,
);
const toSchemas = await this.cliServer.bqrsInfo(
to.completedQuery.query.resultsPaths.resultsPath,
);
const [fromSchemas, toSchemas] = await Promise.all([
this.cliServer.bqrsInfo(
from.completedQuery.query.resultsPaths.resultsPath,
),
this.cliServer.bqrsInfo(to.completedQuery.query.resultsPaths.resultsPath),
]);
const [fromSchemaNames, toSchemaNames] = await Promise.all([
getResultSetNames(
@@ -296,16 +296,18 @@ export class CompareView extends AbstractWebview<
fromResultSetName: string,
toResultSetName: string,
): Promise<RawQueryCompareResult> {
const fromResultSet = await this.getResultSet(
fromInfo.schemas,
fromResultSetName,
from.completedQuery.query.resultsPaths.resultsPath,
);
const toResultSet = await this.getResultSet(
toInfo.schemas,
toResultSetName,
to.completedQuery.query.resultsPaths.resultsPath,
);
const [fromResultSet, toResultSet] = await Promise.all([
this.getResultSet(
fromInfo.schemas,
fromResultSetName,
from.completedQuery.query.resultsPaths.resultsPath,
),
this.getResultSet(
toInfo.schemas,
toResultSetName,
to.completedQuery.query.resultsPaths.resultsPath,
),
]);
return resultsDiff(fromResultSet, toResultSet);
}

View File

@@ -25,20 +25,6 @@ export async function compareInterpretedResults(
fromQuery: CompletedLocalQueryInfo,
toQuery: CompletedLocalQueryInfo,
): Promise<InterpretedQueryCompareResult> {
const fromResultSet = await getInterpretedResults(
fromQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
);
const toResultSet = await getInterpretedResults(
toQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
);
if (!fromResultSet || !toResultSet) {
throw new Error(
"Could not find interpreted results for one or both queries.",
);
}
const database = databaseManager.findDatabaseItem(
Uri.parse(toQuery.initialInfo.databaseInfo.databaseUri),
);
@@ -48,9 +34,21 @@ export async function compareInterpretedResults(
);
}
const sourceLocationPrefix = await database.getSourceLocationPrefix(
cliServer,
);
const [fromResultSet, toResultSet, sourceLocationPrefix] = await Promise.all([
getInterpretedResults(
fromQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
),
getInterpretedResults(
toQuery.completedQuery.query.resultsPaths.interpretedResultsPath,
),
database.getSourceLocationPrefix(cliServer),
]);
if (!fromResultSet || !toResultSet) {
throw new Error(
"Could not find interpreted results for one or both queries.",
);
}
const fromResults = fromResultSet.runs[0].results;
const toResults = toResultSet.runs[0].results;