optimize: use single global set
This commit is contained in:
parent
d33e8daeed
commit
32169b7950
|
|
@ -194,25 +194,22 @@ async function mergeEvents(dir: string, shardReportFiles: string[], stringPool:
|
||||||
printStatus(`merging events`);
|
printStatus(`merging events`);
|
||||||
|
|
||||||
const reports: ReportData[] = [];
|
const reports: ReportData[] = [];
|
||||||
const testIdsUsedInOtherBlobs = new Set<string>();
|
const globalTestIdSet = new Set<string>();
|
||||||
|
|
||||||
for (let i = 0; i < blobs.length; ++i) {
|
for (let i = 0; i < blobs.length; ++i) {
|
||||||
// Generate unique salt for each blob.
|
// Generate unique salt for each blob.
|
||||||
const { parsedEvents, metadata, localPath } = blobs[i];
|
const { parsedEvents, metadata, localPath } = blobs[i];
|
||||||
const eventPatchers = new JsonEventPatchers();
|
const eventPatchers = new JsonEventPatchers();
|
||||||
const testIdsUsedInThisBlob = new Set<string>();
|
|
||||||
eventPatchers.patchers.push(new IdsPatcher(
|
eventPatchers.patchers.push(new IdsPatcher(
|
||||||
stringPool,
|
stringPool,
|
||||||
metadata.name,
|
metadata.name,
|
||||||
String(i),
|
String(i),
|
||||||
testIdsUsedInThisBlob,
|
globalTestIdSet,
|
||||||
testIdsUsedInOtherBlobs,
|
|
||||||
));
|
));
|
||||||
// Only patch path separators if we are merging reports with explicit config.
|
// Only patch path separators if we are merging reports with explicit config.
|
||||||
if (rootDirOverride)
|
if (rootDirOverride)
|
||||||
eventPatchers.patchers.push(new PathSeparatorPatcher(metadata.pathSeparator));
|
eventPatchers.patchers.push(new PathSeparatorPatcher(metadata.pathSeparator));
|
||||||
eventPatchers.patchEvents(parsedEvents);
|
eventPatchers.patchEvents(parsedEvents);
|
||||||
testIdsUsedInThisBlob.forEach(id => testIdsUsedInOtherBlobs.add(id));
|
|
||||||
|
|
||||||
for (const event of parsedEvents) {
|
for (const event of parsedEvents) {
|
||||||
if (event.method === 'onConfigure')
|
if (event.method === 'onConfigure')
|
||||||
|
|
@ -368,22 +365,19 @@ class IdsPatcher {
|
||||||
private _botName: string | undefined;
|
private _botName: string | undefined;
|
||||||
private _salt: string;
|
private _salt: string;
|
||||||
private _testIdsMap: Map<string, string>;
|
private _testIdsMap: Map<string, string>;
|
||||||
private _testIdsUsedInThisBlob: Set<string>;
|
private _globalTestIdSet: Set<string>;
|
||||||
private _testIdsUsedInOtherBlobs: Set<string>;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
stringPool: StringInternPool,
|
stringPool: StringInternPool,
|
||||||
botName: string | undefined,
|
botName: string | undefined,
|
||||||
salt: string,
|
salt: string,
|
||||||
testIdsUsedInThisBlob: Set<string>,
|
globalTestIdSet: Set<string>,
|
||||||
testIdsUsedInOtherBlobs: Set<string>,
|
|
||||||
) {
|
) {
|
||||||
this._stringPool = stringPool;
|
this._stringPool = stringPool;
|
||||||
this._botName = botName;
|
this._botName = botName;
|
||||||
this._salt = salt;
|
this._salt = salt;
|
||||||
this._testIdsMap = new Map();
|
this._testIdsMap = new Map();
|
||||||
this._testIdsUsedInThisBlob = testIdsUsedInThisBlob;
|
this._globalTestIdSet = globalTestIdSet;
|
||||||
this._testIdsUsedInOtherBlobs = testIdsUsedInOtherBlobs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
patchEvent(event: JsonEvent) {
|
patchEvent(event: JsonEvent) {
|
||||||
|
|
@ -431,14 +425,14 @@ class IdsPatcher {
|
||||||
if (this._testIdsMap.has(t1))
|
if (this._testIdsMap.has(t1))
|
||||||
// already mapped
|
// already mapped
|
||||||
return this._testIdsMap.get(t1)!;
|
return this._testIdsMap.get(t1)!;
|
||||||
if (this._testIdsUsedInOtherBlobs.has(t1)) {
|
if (this._globalTestIdSet.has(t1)) {
|
||||||
// test id is used in another blob, so we need to salt it.
|
// test id is used in another blob, so we need to salt it.
|
||||||
const t2 = this._stringPool.internString(testId + this._salt);
|
const t2 = this._stringPool.internString(testId + this._salt);
|
||||||
this._testIdsUsedInThisBlob.add(t2);
|
this._globalTestIdSet.add(t2);
|
||||||
this._testIdsMap.set(t1, t2);
|
this._testIdsMap.set(t1, t2);
|
||||||
return t2;
|
return t2;
|
||||||
}
|
}
|
||||||
this._testIdsUsedInThisBlob.add(t1);
|
this._globalTestIdSet.add(t1);
|
||||||
this._testIdsMap.set(t1, t1);
|
this._testIdsMap.set(t1, t1);
|
||||||
return t1;
|
return t1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue