1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-30 11:16:38 -05:00
denoland-deno/tools/build_benchmark_jsons.js
David Sherret 2fee8394a9
chore: update copyright year to 2023 (#17247)
Yearly tradition of creating extra noise in git.
2023-01-05 13:05:49 +01:00

31 lines
986 B
JavaScript
Executable file

// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { buildPath, existsSync, join } from "./util.js";
const currentDataFile = join(buildPath(), "bench.json");
const allDataFile = "gh-pages/data.json"; // Includes all benchmark data.
const recentDataFile = "gh-pages/recent.json"; // Includes recent 20 benchmark data.
function readJson(filename) {
return JSON.parse(Deno.readTextFileSync(filename));
}
function writeJson(filename, data) {
return Deno.writeTextFileSync(filename, JSON.stringify(data));
}
if (!existsSync(currentDataFile)) {
throw new Error(`${currentDataFile} doesn't exist`);
}
if (!existsSync(allDataFile)) {
throw new Error(`${allDataFile} doesn't exist`);
}
const newData = readJson(currentDataFile);
const allData = readJson(allDataFile);
allData.push(newData);
const allDataLen = allData.length;
const recentData = allData.slice(allDataLen - 20);
writeJson(allDataFile, allData);
writeJson(recentDataFile, recentData);