diff --git a/scripts/download-benchmarks.js b/scripts/download-benchmarks.js
index 3cdab73a..b59c04b2 100644
--- a/scripts/download-benchmarks.js
+++ b/scripts/download-benchmarks.js
@@ -44,12 +44,14 @@ async function execute({ downloadUrl, outputFile }) {
async function downloadBenchmarks(githubUrl) {
const data = await getDataAsJSON(githubUrl)
if (isValidBenchmark(data)) {
- return buildBenchmarksJSON(data)
+ const date = await getBenchmarkDate()
+ return buildBenchmarksJSON(data, date)
}
log.warn('Fetched file contains `N/A` data. Searching for previous revision')
const commits = await getCommits()
+ let i = 0
for (let commit in commits) {
const commitSha = commits[commit]
log.debug(`Checking commit %s`, commitSha)
@@ -59,13 +61,20 @@ async function downloadBenchmarks(githubUrl) {
const data = await getBlob(benchmarlUrl)
if (isValidBenchmark(data)) {
- return buildBenchmarksJSON(data)
+ const date = await getBenchmarkDate(i)
+ return buildBenchmarksJSON(data, date)
}
+ i++
}
throw new Error('Unable to find a valid benchmark result')
}
+async function getBenchmarkDate(benchmarkCommitNumber = 0) {
+ const commits = await getDataAsJSON(`${GITHUB_BASE_URL}/commits?path=benchmark-results.json&per_page=10`)
+ return commits[benchmarkCommitNumber] ? commits[benchmarkCommitNumber].commit.committer.date : 'Unknown'
+}
+
const getCommits = async () => {
const commits = await getDataAsJSON(`${GITHUB_BASE_URL}/commits?path=benchmark-results.json&per_page=10`)
return commits.map((commit) => commit.sha)
@@ -87,13 +96,14 @@ const getBlob = async (blobUrl) => {
return JSON.parse(decodedContent)
}
-function buildBenchmarksJSON(data) {
+function buildBenchmarksJSON(data, date = 'Unknown') {
const maxSpeed = data
.filter(({ requests }) => !isNaN(requests))
.map(({ requests }) => parseInt(requests))
.reduce((max, req) => (req > max ? req : max), 0)
const json = {
+ date,
reference: maxSpeed,
frameworks: arrayDefaultFrameworks.map((framework) => {
const item = data.find(({ name }) => name == framework.tag)
diff --git a/src/pages/benchmarks.mdx b/src/pages/benchmarks.mdx
index d5048981..90f83ffd 100644
--- a/src/pages/benchmarks.mdx
+++ b/src/pages/benchmarks.mdx
@@ -16,13 +16,19 @@ export function BenchmarkSection() {
))
}
+export function BenchMarkDate() {
+ return benchmarksData.date === 'Unknown'
+ ? 'Unknown'
+ : new Date(benchmarksData.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })
+}
+
Leveraging our experience with Node.js performance, Fastify has been built from the ground up to be **as fast as possible**.
All the code used for our benchmarks is [available on GitHub](https://github.com/fastify/benchmarks/).
-Here's a brief summary on how Fastify overhead performed against the some other well known Node.js web frameworks:
+Here's a brief summary on how Fastify overhead performed against the some other well known Node.js web frameworks (last updated on ):