Skip to content

Commit

Permalink
chore: enable formatting perf-measures (#3683)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe authored Nov 18, 2024
1 parent 53bd319 commit c8f6a86
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"test:all": "bun run test && bun test:deno && bun test:bun && bun test:fastly && bun test:node && bun test:workerd && bun test:lambda && bun test:lambda-edge",
"lint": "eslint src runtime-tests",
"lint:fix": "eslint src runtime-tests --fix",
"format": "prettier --check --cache \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\" \"build/**/*.{js,ts,tsx}\"",
"format:fix": "prettier --write --cache --cache-strategy metadata \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\" \"build/**/*.{js,ts,tsx}\"",
"format": "prettier --check --cache \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\" \"build/**/*.{js,ts,tsx}\" \"perf-measures/**/*.{js,ts,tsx}\"",
"format:fix": "prettier --write --cache --cache-strategy metadata \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\" \"build/**/*.{js,ts,tsx}\" \"perf-measures/**/*.{js,ts,tsx}\"",
"copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json",
"build": "bun run --shell bun remove-dist && bun ./build/build.ts && bun run copy:package.cjs.json",
"postbuild": "publint",
Expand Down Expand Up @@ -654,4 +654,4 @@
"engines": {
"node": ">=16.9.0"
}
}
}
16 changes: 8 additions & 8 deletions perf-measures/bundle-check/scripts/process-results.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as fs from 'node:fs/promises'

async function main() {
const currentResult = (await fs.readFile('./generated/after.js')).byteLength
let previousResult: number | null = null
try {
previousResult = (await fs.readFile('./generated/before.js')).byteLength
} catch (e) {}
const table = ['| | Current | Previous |', '| --- | --- | --- |']
table.push(`| Bundle Size | ${currentResult} | ${previousResult || 'N/A'} |`)
console.log(table.join('\n'))
const currentResult = (await fs.readFile('./generated/after.js')).byteLength
let previousResult: number | null = null
try {
previousResult = (await fs.readFile('./generated/before.js')).byteLength
} catch (e) {}
const table = ['| | Current | Previous |', '| --- | --- | --- |']
table.push(`| Bundle Size | ${currentResult} | ${previousResult || 'N/A'} |`)
console.log(table.join('\n'))
}

main()
4 changes: 3 additions & 1 deletion perf-measures/type-check/scripts/generate-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const app = new Hono()`
const routes = generateRoutes(count)

writeFile(path.join(import.meta.dirname, '../generated/app.ts'), routes, (err) => {
if (err) { throw err }
if (err) {
throw err
}
console.log(`${count} routes have been written to app.ts`)
})
25 changes: 14 additions & 11 deletions perf-measures/type-check/scripts/process-results.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import * as fs from 'node:fs/promises'

async function main() {
const currentResult = (await fs.readFile('./result.txt')).toString().split('\n')
const previousResult = await fs.readFile('./previous-result.txt')
.then((data) => data.toString().split('\n'))
.catch(() => null)
const table = ['| | Current | Previous |', '| --- | --- | --- |']
for (const [i, line] of currentResult.entries()) {
if (line === '') {continue}
const [name, value] = line.split(':')
const mainValue = previousResult?.[i]?.split(':')?.[1]
table.push(`| ${name?.trim()} | ${value?.trim()} | ${mainValue ? mainValue.trim() : 'N/A'} |`)
const currentResult = (await fs.readFile('./result.txt')).toString().split('\n')
const previousResult = await fs
.readFile('./previous-result.txt')
.then((data) => data.toString().split('\n'))
.catch(() => null)
const table = ['| | Current | Previous |', '| --- | --- | --- |']
for (const [i, line] of currentResult.entries()) {
if (line === '') {
continue
}
console.log(table.join('\n'))
const [name, value] = line.split(':')
const mainValue = previousResult?.[i]?.split(':')?.[1]
table.push(`| ${name?.trim()} | ${value?.trim()} | ${mainValue ? mainValue.trim() : 'N/A'} |`)
}
console.log(table.join('\n'))
}

main()

0 comments on commit c8f6a86

Please sign in to comment.