Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add last update time at /benchmarks page #198

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions scripts/download-benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion src/pages/benchmarks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
}

<HeroBanner title="Benchmarks" />

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 <BenchMarkDate />):

<BenchmarkSection />

Expand Down
Loading