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 tiny http #304

Merged
merged 1 commit into from
Oct 26, 2023
Merged
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
9 changes: 9 additions & 0 deletions benchmarks/tinyhttp.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { App } from '@tinyhttp/app'

const app = new App()

app.get('/', (_, res) => {
res.send('Hello World!')
})

app.listen(3000)
2 changes: 2 additions & 0 deletions lib/autocannon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { writeFile as _writeFile, mkdir as _mkdir, access as _access } from 'fs'
import compare from 'autocannon-compare'
import { join } from 'path'
import { promisify } from 'util'
import { createRequire } from 'module'

const writeFile = promisify(_writeFile)
const mkdir = promisify(_mkdir)
const access = promisify(_access)
const require = createRequire(import.meta.url)
dancastillo marked this conversation as resolved.
Show resolved Hide resolved

const resultsDirectory = join(process.cwd(), 'results')

Expand Down
10 changes: 9 additions & 1 deletion lib/bench.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
'use strict'

import { access } from 'node:fs/promises'
import { fork } from 'child_process'
import ora from 'ora'
import { join } from 'path'
Expand All @@ -12,7 +13,14 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url))

const doBench = async (opts, handler) => {
const spinner = ora(`Started ${handler}`).start()
const forked = fork(join(__dirname, '..', 'benchmarks', handler + '.cjs'))
let forked
try {
await access(join(__dirname, '..', 'benchmarks', handler + '.cjs'))
forked = fork(join(__dirname, '..', 'benchmarks', handler + '.cjs'))
} catch {
forked = fork(join(__dirname, '..', 'benchmarks', handler + '.mjs'))
}

try {
spinner.color = 'magenta'
spinner.text = `Warming ${handler}`
Expand Down
1 change: 1 addition & 0 deletions lib/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const packages = {
spirit: { extra: true },
'spirit-router': { extra: true, hasRouter: true },
'take-five': { hasRouter: true },
tinyhttp: { package: '@tinyhttp/app' },
'total.js': { hasRouter: true },
'trpc-router': { extra: true, hasRouter: true, package: '@trpc/server' },
vapr: { hasRouter: true },
Expand Down
Loading