deno.land / x / deno@v1.28.2 / tools / build_benchmark_jsons.js

build_benchmark_jsons.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2018-2022 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);
deno

Version Info

Tagged at
a year ago