Store times in numbers only (#7023)

Also fixes #4655
This commit is contained in:
Ofek
2024-10-26 18:43:59 +03:00
committed by GitHub
parent 4fe8397fac
commit f6438f9c4d
20 changed files with 44 additions and 45 deletions

View File

@@ -1966,7 +1966,7 @@ export class BaseCompiler implements ICompiler {
inputFilename: inputFilename,
dirPath: dirPath,
executableFilename: this.getExecutableFilename(dirPath, this.outputFilebase, key),
packageDownloadAndUnzipTime: ((endTime - startTime) / BigInt(1000000)).toString(),
packageDownloadAndUnzipTime: utils.deltaTimeNanoToMili(startTime, endTime),
});
}
logger.debug('Tried to get executable from cache, but got a cache miss');
@@ -2904,10 +2904,7 @@ export class BaseCompiler implements ICompiler {
const result = await this.env.cacheGet(key as any);
if (result) {
const cacheRetrieveTimeEnd = process.hrtime.bigint();
result.retreivedFromCacheTime = (
(cacheRetrieveTimeEnd - cacheRetrieveTimeStart) /
BigInt(1000000)
).toString();
result.retreivedFromCacheTime = utils.deltaTimeNanoToMili(cacheRetrieveTimeStart, cacheRetrieveTimeEnd);
result.retreivedFromCache = true;
if (doExecute) {
const queueTime = performance.now();

View File

@@ -1,5 +1,5 @@
export type BuildEnvDownloadInfo = {
step: string;
packageUrl: string;
time: string;
time: number;
};

View File

@@ -35,10 +35,10 @@ import {CompilerInfo} from '../../types/compiler.interfaces.js';
import {CompilationEnvironment} from '../compilation-env.js';
import {logger} from '../logger.js';
import {VersionInfo} from '../options-handler.js';
import * as utils from '../utils.js';
import {BuildEnvSetupBase} from './base.js';
import type {BuildEnvDownloadInfo} from './buildenv.interfaces.js';
// import { CompilationEnvironment } from '../compilation-env.js';
export type ConanBuildProperties = {
os: string;
@@ -189,7 +189,7 @@ export class BuildEnvSetupCeConanDirect extends BuildEnvSetupBase {
resolve({
step: `Download of ${libId} ${version}`,
packageUrl: packageUrl,
time: ((endTime - startTime) / BigInt(1000000)).toString(),
time: utils.deltaTimeNanoToMili(startTime, endTime),
});
});

View File

@@ -128,7 +128,7 @@ export class AssemblyCompiler extends BaseCompiler {
okToCache: false,
filenameTransform: (fn: string) => fn,
stdout: [],
execTime: '',
execTime: 0,
timedOut: false,
compilationOptions: [],
};

View File

@@ -35,6 +35,7 @@ import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.in
import {BaseCompiler} from '../base-compiler.js';
import * as exec from '../exec.js';
import {logger} from '../logger.js';
import * as utils from '../utils.js';
interface ASICSelection {
asic?: string;
@@ -101,10 +102,6 @@ Please supply an ASIC from the following options:`,
};
}
execTime(startTime: bigint, endTime: bigint): string {
return ((endTime - startTime) / BigInt(1000000)).toString();
}
override async runCompiler(
compiler: string,
options: string[],
@@ -153,7 +150,7 @@ Please supply an ASIC from the following options:`,
okToCache: true,
filenameTransform: (x: string) => x,
stdout: asicSelection.error,
execTime: this.execTime(startTime, endTime),
execTime: utils.deltaTimeNanoToMili(startTime, endTime),
};
}
@@ -161,7 +158,7 @@ Please supply an ASIC from the following options:`,
if (dxcResult.code !== 0) {
// Failed to compile SPIR-V intermediate product. Exit immediately with DXC invocation result.
const endTime = process.hrtime.bigint();
dxcResult.execTime = this.execTime(startTime, endTime);
dxcResult.execTime = utils.deltaTimeNanoToMili(startTime, endTime);
return dxcResult;
}
@@ -174,7 +171,7 @@ Please supply an ASIC from the following options:`,
okToCache: true,
filenameTransform: (x: string) => x,
stdout: 'Failed to emit intermediate SPIR-V result.',
execTime: this.execTime(startTime, endTime),
execTime: utils.deltaTimeNanoToMili(startTime, endTime),
};
}
@@ -196,7 +193,7 @@ Please supply an ASIC from the following options:`,
if (rgaResult.code !== 0) {
// Failed to compile AMD ISA
const endTime = process.hrtime.bigint();
rgaResult.execTime = this.execTime(startTime, endTime);
rgaResult.execTime = utils.deltaTimeNanoToMili(startTime, endTime);
return rgaResult;
}
@@ -263,14 +260,14 @@ where [ASIC] corresponds to one of the following options:`;
}
const endTime = process.hrtime.bigint();
rgaResult.execTime = this.execTime(startTime, endTime);
rgaResult.execTime = utils.deltaTimeNanoToMili(startTime, endTime);
return rgaResult;
}
}
// Arriving here means the expected ISA result wasn't emitted. Synthesize an error.
const endTime = process.hrtime.bigint();
rgaResult.execTime = this.execTime(startTime, endTime);
rgaResult.execTime = utils.deltaTimeNanoToMili(startTime, endTime);
rgaResult.stdout += `\nRGA didn't emit expected ISA output.`;
return rgaResult;
}

View File

@@ -39,6 +39,7 @@ import {assert, unwrap, unwrapString} from './assert.js';
import {logger} from './logger.js';
import {Graceful} from './node-graceful.js';
import {propsFor} from './properties.js';
import * as utils from './utils.js';
type NsJailOptions = {
args: string[];
@@ -174,7 +175,7 @@ export function executeDirect(
stdout: streams.stdout,
stderr: streams.stderr,
truncated: streams.truncated,
execTime: ((endTime - startTime) / BigInt(1000000)).toString(),
execTime: utils.deltaTimeNanoToMili(startTime, endTime),
};
// Check debug level explicitly as result may be a very large string
// which we'd prefer to avoid preparing if it won't be used

View File

@@ -118,7 +118,7 @@ export class LocalExecutionEnvironment implements IExecutionEnvironment {
inputFilename: inputFilename,
dirPath: dirPath,
executableFilename: executableFilename,
packageDownloadAndUnzipTime: ((endTime - startTime) / BigInt(1000000)).toString(),
packageDownloadAndUnzipTime: utils.deltaTimeNanoToMili(startTime, endTime),
});
} else {
throw new ExecutablePackageCacheMiss('Tried to get executable from cache, but got a cache miss');

View File

@@ -14,7 +14,7 @@ export class AsmParserBeebAsm extends AsmParser {
this.asmOpcodeRe = /^\s*(?<address>[\dA-F]+)\s*(?<opcodes>([\dA-F]{2} ?)+)\s*(?<disasm>.*)/;
}
override processAsm(asm: string, filters: ParseFiltersAndOutputOptions): ParsedAsmResult {
override processAsm(asm: string, _filters: ParseFiltersAndOutputOptions): ParsedAsmResult {
const startTime = process.hrtime.bigint();
const asmLines: ParsedAsmResultLine[] = [];
@@ -52,7 +52,7 @@ export class AsmParserBeebAsm extends AsmParser {
return {
asm: asmLines,
labelDefinitions: labelDefinitions,
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: startingLineCount - asm.length,
};
}

View File

@@ -71,7 +71,7 @@ export class AsmParserCpp implements IAsmParser {
return {
asm: asm,
labelDefinitions: {},
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: 0,
};
}

View File

@@ -168,7 +168,7 @@ export class DartAsmParser extends AsmParser {
return {
asm: asm,
labelDefinitions: labelDefinitions,
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: startingLineCount - asm.length,
};
}

View File

@@ -22,6 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import * as utils from '../utils.js';
@@ -133,7 +134,7 @@ export class DotNetAsmParser implements IAsmParser {
return cleanedAsm;
}
process(asmResult: string, filters: ParseFiltersAndOutputOptions) {
process(asmResult: string, filters: ParseFiltersAndOutputOptions): ParsedAsmResult {
const startTime = process.hrtime.bigint();
const asm: {
@@ -198,7 +199,7 @@ export class DotNetAsmParser implements IAsmParser {
return {
asm: asm,
labelDefinitions: Object.fromEntries(labelDefinitions.filter(i => i[1] !== -1)),
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: startingLineCount - asm.length,
};
}

View File

@@ -232,7 +232,7 @@ export class MadsAsmParser extends AsmParser {
return {
asm: asm,
labelDefinitions: labelDefinitions,
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: startingLineCount - asm.length,
languageId: 'asm6502',
};

View File

@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import {AsmResultLabel, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js';
import {AsmResultLabel, ParsedAsmResult, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import * as utils from '../utils.js';
@@ -85,7 +85,7 @@ export class SPIRVAsmParser extends AsmParser {
return labelsInLine;
}
override processAsm(asmResult, filters: ParseFiltersAndOutputOptions) {
override processAsm(asmResult, filters: ParseFiltersAndOutputOptions): ParsedAsmResult {
const startTime = process.hrtime.bigint();
const asm: ParsedAsmResultLine[] = [];
@@ -183,7 +183,7 @@ export class SPIRVAsmParser extends AsmParser {
asm: asm,
labelDefinitions,
languageId: 'spirv',
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: startingLineCount - asm.length,
};
}

View File

@@ -188,7 +188,7 @@ export class AsmParserZ88dk extends AsmParser {
return {
asm: asm,
labelDefinitions: labelDefinitions,
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: startingLineCount - asm.length,
};
}
@@ -260,7 +260,7 @@ export class AsmParserZ88dk extends AsmParser {
return {
asm: asm,
labelDefinitions: labelDefinitions,
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: startingLineCount - asm.length,
};
}

View File

@@ -673,7 +673,7 @@ export class AsmParser extends AsmRegex implements IAsmParser {
return {
asm: asm,
labelDefinitions: labelDefinitions,
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: startingLineCount - asm.length,
};
}
@@ -829,7 +829,7 @@ export class AsmParser extends AsmRegex implements IAsmParser {
return {
asm: asm,
labelDefinitions: labelDefinitions,
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
parsingTime: utils.deltaTimeNanoToMili(startTime, endTime),
filteredCount: startingLineCount - asm.length,
};
}

View File

@@ -533,7 +533,11 @@ export function getEmptyExecutionResult(): BasicExecutionResult {
filenameTransform: x => x,
stdout: [],
stderr: [],
execTime: '',
execTime: 0,
timedOut: false,
};
}
export function deltaTimeNanoToMili(startTime: bigint, endTime: bigint): number {
return Number((endTime - startTime) / BigInt(1_000_000));
}

View File

@@ -200,7 +200,7 @@ ${' '.repeat(65530)}x
ret
`;
const output = parser.process(asm, filters);
expect(parseInt(unwrap(output.parsingTime))).toBeLessThan(500); // reported as ms, generous timeout for ci runner
expect(unwrap(output.parsingTime)).toBeLessThan(500); // reported as ms, generous timeout for ci runner
});
});
@@ -229,6 +229,6 @@ ${' '.repeat(65530)}x
ret
`;
const output = parser.process(asm, filters);
expect(parseInt(unwrap(output.parsingTime))).toBeLessThan(500); // reported as ms, generous timeout for ci runner
expect(unwrap(output.parsingTime)).toBeLessThan(500); // reported as ms, generous timeout for ci runner
});
});

View File

@@ -34,12 +34,11 @@ export type ParsedAsmResultLine = {
export type ParsedAsmResult = {
asm: ParsedAsmResultLine[];
labelDefinitions?: Record<string, number>;
parsingTime?: string;
parsingTime?: number;
filteredCount?: number;
externalParserUsed?: boolean;
// TODO(#4655) A few compilers seem to assign strings here. It might be ok but we should look into it more.
objdumpTime?: number | string;
execTime?: string;
objdumpTime?: number;
execTime?: number;
languageId?: string;
};

View File

@@ -216,7 +216,7 @@ export type CompilationResult = {
retreivedFromCache?: boolean;
retreivedFromCacheTime?: number;
packageDownloadAndUnzipTime?: number;
execTime?: number | string;
execTime?: number;
processExecutionResultTime?: number;
objdumpTime?: number;
parsingTime?: number;

View File

@@ -8,7 +8,7 @@ export type UnprocessedExecResult = {
filenameTransform: FilenameTransformFunc;
stdout: string;
stderr: string;
execTime: string;
execTime: number;
timedOut: boolean;
languageId?: string;
truncated: boolean;
@@ -26,7 +26,7 @@ export type BasicExecutionResult = {
filenameTransform: FilenameTransformFunc;
stdout: ResultLine[];
stderr: ResultLine[];
execTime: string;
execTime: number;
processExecutionResultTime?: number;
timedOut: boolean;
languageId?: string;