Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function writeResult(res: Result, dir: string) {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
let benchmark = res.benchmark;
let framework = res.framework.name;
let data = res.results;
data = data.slice(0).sort((a: number, b: number) => a - b);
// data = data.slice(0, config.REPEAT_RUN - config.DROP_WORST_RUN);
let s = jStat(data);
console.log(
`result ${fileName(
res.framework,
benchmark
)} min ${s.min()} max ${s.max()} mean ${s.mean()} median ${s.median()} stddev ${s.stdev()}`
);
let result: JSONResult = {
framework: framework,
benchmark: benchmark.id,
type: benchmark.type === BenchmarkType.CPU ? 'cpu' : 'memory',
min: s.min(),
max: s.max(),
mean: s.mean(),
median: s.median(),
geometricMean: s.geomean(),
standardDeviation: s.stdev(),
function writeResult(res: Result) {
if (!config.WRITE_RESULTS) return;
const benchmark = res.benchmark;
const framework = res.framework.name;
const keyed = res.framework.keyed;
let type = null;
switch (benchmark.type) {
case BenchmarkType.CPU: type = "cpu"; break;
case BenchmarkType.MEM: type = "memory"; break;
case BenchmarkType.STARTUP: type = "startup"; break;
}
for (const resultKind of benchmark.resultKinds()) {
const data = benchmark.extractResult(res.results, resultKind);
const s = jStat(data);
console.log(`result ${fileName(res.framework, resultKind)} min ${s.min()} max ${s.max()} mean ${s.mean()} median ${s.median()} stddev ${s.stdev(true)}`);
const result: JSONResult = {
"framework": res.framework.fullNameWithKeyedAndVersion,
"keyed": keyed,
"benchmark": resultKind.id,
"type": type,
"min": s.min(),
"max": s.max(),
"mean": s.mean(),
"median": s.median(),
"geometricMean": s.geomean(),
"standardDeviation": s.stdev(true),
"values": data
};
fs.writeFileSync(`${config.RESULTS_DIRECTORY}/${fileName(res.framework, resultKind)}`, JSON.stringify(result), {encoding: "utf8"});
}
function writeResult(res: Result) {
if (!config.WRITE_RESULTS) return;
let benchmark = res.benchmark;
let framework = res.framework.name;
let keyed = res.framework.keyed;
let type = null;
switch (benchmark.type) {
case BenchmarkType.CPU: type = "cpu"; break;
case BenchmarkType.MEM: type = "memory"; break;
case BenchmarkType.STARTUP: type = "startup"; break;
}
for (let resultKind of benchmark.resultKinds()) {
let data = benchmark.extractResult(res.results, resultKind);
let s = jStat(data);
console.log(`result ${fileName(res.framework, resultKind)} min ${s.min()} max ${s.max()} mean ${s.mean()} median ${s.median()} stddev ${s.stdev(true)}`);
let result: JSONResult = {
"framework": res.framework.fullNameWithKeyedAndVersion,
"keyed": keyed,
"benchmark": resultKind.id,
"type": type,
"min": s.min(),
"max": s.max(),
"mean": s.mean(),
"median": s.median(),
"geometricMean": s.geomean(),
"standardDeviation": s.stdev(true),
"values": data
}
fs.writeFileSync(`${config.RESULTS_DIRECTORY}/${fileName(res.framework, resultKind)}`, JSON.stringify(result), {encoding: "utf8"});
}
const results = [];
switch (benchmark.type) {
case BenchmarkType.CPU:
type = 'cpu';
break;
case BenchmarkType.MEM:
type = 'memory';
break;
case BenchmarkType.STARTUP:
type = 'startup';
break;
}
for (let resultKind of benchmark.resultKinds()) {
let data = benchmark.extractResult(res.results, resultKind);
let s = jStat(data);
console.log(
`result ${framework} ${resultKind.id} min ${s.min()} max ${s.max()} mean ${s.mean()} median ${s.median()} stddev ${s.stdev(
true
)}`
);
let result = {
framework: res.framework,
keyed: keyed,
benchmark: resultKind.id,
type: type,
min: s.min(),
max: s.max(),
mean: s.mean(),
median: s.median(),
geometricMean: s.geomean(),
standardDeviation: s.stdev(true),