chore: format and lint `benchmarks/*` (#4317)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* chore: format and lint `benchmarks/*` * fomrat
authored by Yusuke Wada · committed by GitHub · parent 46f484c · Browse files · 16 files·+26 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
16 files+26 added−23 removed
- other:+26 added−23 removed
Provenance
- Commit
0d12626- Tree
7de8b6c- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
GitHub <noreply@github.com>- Parent
46f484c
16 files changed+26 added−23 removed
modified:benchmarks/deno/fast.ts+2 added-1 removed
112345615 unmodified linesimport fast, { type Context } from 'https://deno.land/x/fast@4.0.0-beta.1/mod.ts'import fast from 'https://deno.land/x/fast@4.0.0-beta.1/mod.ts'import type { Context } from 'https://deno.land/x/fast@4.0.0-beta.1/mod.ts'
const app = fast()
app.get('/user', () => {})15 unmodified linesmodified:benchmarks/handle-event/index.js+1 added
109 unmodified linesExpand all11011111211311411511611711832 unmodified lines109 unmodified linesExpand all
makeEdgeEnv()
// FetchEvent Object// eslint-disable-next-line no-undefconst event = new FetchEvent('fetch', { request })
const fn = async () => { let res = await hono.fetch(event.request)32 unmodified linesmodified:benchmarks/http-server/benchmark.ts+3 added-2 removed
17 unmodified lines18 import { existsSync, mkdirSync, writeFileSync, rmSync } from 'node:fs'19 import { join } from 'node:path'20 21 // Configuration from command line arguments22+const baseline =22-const baseline = process.argv.find((arg) => arg.startsWith('--baseline='))?.split('=')[1] || 'origin/main'23+ process.argv.find((arg) => arg.startsWith('--baseline='))?.split('=')[1] || 'origin/main'24 const target = process.argv.find((arg) => arg.startsWith('--target='))?.split('=')[1] || 'current'25 const runs = parseInt(process.argv.find((arg) => arg.startsWith('--runs='))?.split('=')[1] || '1')26 const duration = parseInt(27 process.argv.find((arg) => arg.startsWith('--duration='))?.split('=')[1] || '10'72 unmodified lines100 // No build needed - use src directly101 } else {102 // Ensure we have the latest remote refs103 await runCommand('git fetch origin', HONO_ROOT)103- 104+105 try {106 const stashResult = await runCommand('git stash push -m "benchmark-temp"', HONO_ROOT)107 needsRestore = stashResult.stdout.includes('Saved working directory')108 if (needsRestore) {218 unmodified linesmodified:benchmarks/jsx/src/react-jsx/benchmark.ts+1 added-1 removed
11 unmodified lines12 const html = render()13 const doc = parse(html)14 if (doc.querySelector('p#c').textContent !== '3\nc') {15 throw new Error('Invalid output')16- } 16+ }17 })18 19 suite20 .add('Hono', () => {18 unmodified linesmodified:benchmarks/jsx/src/react-jsx/hono.ts+1 added-1 removed
1233import { buildPage } from './page-hono'
export const render = () => buildPage()().toString()No newline at end of fileexport const render = () => buildPage()().toString()modified:benchmarks/jsx/src/react-jsx/nano.ts+1 added-1 removed
12344import { renderSSR } from 'nano-jsx'import { buildPage } from './page-nano.tsx'
export const render = () => renderSSR(buildPage())No newline at end of fileexport const render = () => renderSSR(buildPage())modified:benchmarks/jsx/src/react-jsx/preact.ts+1 added-1 removed
12344import { renderToString } from 'preact-render-to-string'import { buildPage } from './page-preact'
export const render = () => renderToString(buildPage()() as any)No newline at end of fileexport const render = () => renderToString(buildPage()() as any)modified:benchmarks/jsx/src/benchmark.ts+1 added-1 removed
11 unmodified lines12 const html = render()13 const doc = parse(html)14 if (doc.querySelector('p#c').textContent !== '3\nc') {15 throw new Error('Invalid output')16- } 16+ }17 })18 19 suite20 .add('Hono', () => {18 unmodified linesmodified:benchmarks/jsx/src/hono.ts+2 added-2 removed
1-import { jsx, Fragment} from '../../../src/jsx'1+import { jsx, Fragment } from '../../../src/jsx'2 import { buildPage } from './page'3 4-export const render = () => buildPage({ jsx, Fragment })().toString()4+export const render = () => buildPage({ jsx, Fragment })().toString()modified:benchmarks/jsx/src/nano.ts+1 added-1 removed
1 import { h, Fragment, renderSSR } from 'nano-jsx'2 import { buildPage } from './page'3 4-export const render = () => renderSSR(buildPage({ jsx: h, Fragment }))4+export const render = () => renderSSR(buildPage({ jsx: h, Fragment }))modified:benchmarks/jsx/src/preact.ts+2 added-2 removed
1-import { h, Fragment} from 'preact'1+import { h, Fragment } from 'preact'2 import { renderToString } from 'preact-render-to-string'3 import { buildPage } from './page'4 5-export const render = () => renderToString(buildPage({ jsx: h, Fragment })() as any)5+export const render = () => renderToString(buildPage({ jsx: h, Fragment })() as any)modified:benchmarks/routers/src/bench.mts+1 added-1 removed
5 unmodified lines6 import { koaTreeRouter } from './koa-tree-router.mts'7 import { medleyRouter } from './medley-router.mts'8 import { memoiristRouter } from './memoirist.mts'9 import { radix3Router } from './radix3.mts'10+import { rou3Router } from './rou3.mts'11 import type { Route, RouterInterface } from './tool.mts'12 import { trekRouter } from './trek-router.mts'12-import { rou3Router } from './rou3.mts'13 14 const routers: RouterInterface[] = [15 regExpRouter,16 trieRouter,73 unmodified linesmodified:benchmarks/routers/src/hono.mts+1 added-1 removed
1+import { PatternRouter } from '../../../src/router/pattern-router/index.ts'2 import { RegExpRouter } from '../../../src/router/reg-exp-router/index.ts'3 import { TrieRouter } from '../../../src/router/trie-router/index.ts'3-import { PatternRouter } from '../../../src/router/pattern-router/index.ts'4 import type { Router } from '../../../src/router.ts'5 import type { RouterInterface } from './tool.mts'6 import { routes, handler } from './tool.mts'7 15 unmodified linesmodified:benchmarks/routers-deno/src/hono.mts+2 added-2 removed
1-import type { Router } from '../../../src/router.ts'1+import { PatternRouter } from '../../../src/router/pattern-router/index.ts'2 import { RegExpRouter } from '../../../src/router/reg-exp-router/index.ts'3 import { TrieRouter } from '../../../src/router/trie-router/index.ts'4-import { PatternRouter } from '../../../src/router/pattern-router/index.ts'4+import type { Router } from '../../../src/router.ts'5 import type { RouterInterface } from './tool.mts'6 import { routes, handler } from './tool.mts'7 8 const createHonoRouter = (name: string, router: Router<unknown>): RouterInterface => {14 unmodified linesmodified:benchmarks/utils/src/get-path.ts+1 added-1 removed
23 unmodified lines24 })25 26 bench('slice + for-loop + flag', () => {27 const url = request.url28- let start = url.indexOf('/', 8)28+ const start = url.indexOf('/', 8)29 let i = start30 let hasPercentEncoding = false31 for (; i < url.length; i++) {32 const charCode = url.charCodeAt(i)34 unmodified linesmodified:package.json+5 added-5 removed
18 unmodified lines19 "test:workerd": "vitest --run --config ./runtime-tests/workerd/vitest.config.ts",20 "test:lambda": "vitest --run --config ./runtime-tests/lambda/vitest.config.ts",21 "test:lambda-edge": "vitest --run --config ./runtime-tests/lambda-edge/vitest.config.ts",22 "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",23- "lint": "eslint src runtime-tests build perf-measures",24- "lint:fix": "eslint src runtime-tests build perf-measures --fix",25- "format": "prettier --check --cache \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\" \"build/**/*.{js,ts,tsx}\" \"perf-measures/**/*.{js,ts,tsx}\"",26- "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}\"",23+ "lint": "eslint src runtime-tests build perf-measures benchmarks",24+ "lint:fix": "eslint src runtime-tests build perf-measures benchmarks --fix",25+ "format": "prettier --check --cache \"src/**/*.{js,ts,tsx}\" \"runtime-tests/**/*.{js,ts,tsx}\" \"build/**/*.{js,ts,tsx}\" \"perf-measures/**/*.{js,ts,tsx}\" \"benchmarks/**/*.{js,ts,tsx}\"",26+ "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}\" \"benchmarks/**/*.{js,ts,tsx}\"",27 "copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json",28 "build": "bun run --shell bun remove-dist && bun ./build/build.ts && bun run copy:package.cjs.json",29 "postbuild": "publint",30 "watch": "bun run --shell bun remove-dist && bun ./build/build.ts --watch && bun run copy:package.cjs.json",653 unmodified lines684 },685 "engines": {686 "node": ">=16.9.0"687 }688-}688+}