From 666c65382b1ff381f5b21aea65c20114911ab694 Mon Sep 17 00:00:00 2001 From: Ryan Block Date: Fri, 3 Nov 2023 13:16:54 -0700 Subject: [PATCH] Fix writing latest results JSON in CI --- bench/index.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bench/index.mjs b/bench/index.mjs index 887cf6c..67f1db0 100644 --- a/bench/index.mjs +++ b/bench/index.mjs @@ -1,4 +1,4 @@ -import { writeFileSync } from 'node:fs' +import { existsSync, mkdirSync, writeFileSync } from 'node:fs' import { join } from 'node:path' import { names as lambdae } from '../src/plugins/lambdas.mjs' import parseResults from './parse-results.mjs' @@ -10,6 +10,7 @@ const coldstartRe = /(?<=(Init Duration: ))[\d.]+(?=( ms))/g const region = process.env.AWS_PROFILE || 'us-west-2' const env = process.env.ARC_ENV === 'production' ? 'Production' : 'Staging' const writeResults = true +const tmp = join(process.cwd(), 'tmp') const runs = 10 // TODO: increase to a statistically significant quantity of runs const stats = {} @@ -116,7 +117,8 @@ async function main () { await aws.DynamoDB.BatchWriteItem(batch) if (writeResults) { - writeFileSync(join(process.cwd(), 'tmp', 'latest-results.json'), JSON.stringify(stats, null, 2)) + if (!existsSync(tmp)) mkdirSync(tmp) + writeFileSync(join(tmp, 'latest-results.json'), JSON.stringify(stats, null, 2)) } parseResults({ results: stats, region })