diff --git a/benchmarks/handle-event/index.js b/benchmarks/handle-event/index.js index 772efe46b..d7a54de8f 100644 --- a/benchmarks/handle-event/index.js +++ b/benchmarks/handle-event/index.js @@ -1,4 +1,4 @@ -import Benchmark from 'benchmark' +import { bench, group, run } from 'mitata' import { makeEdgeEnv } from 'edge-mock' import { Router as IttyRouter } from 'itty-router' import { Request, Response } from 'node-fetch' @@ -113,7 +113,7 @@ makeEdgeEnv() // FetchEvent Object const event = new FetchEvent('fetch', { request }) -const fn = async () => { +const prepare = async () => { let res = await hono.fetch(event.request) console.log(await res.text()) res = await ittyRouter.handle(event.request) @@ -123,27 +123,22 @@ const fn = async () => { res = await worktopRouter.run(event) console.log(await res.text()) } -fn() -const suite = new Benchmark.Suite() +prepare() -suite - .add('Hono', async () => { +group(() => { + bench('Hono', async () => { await hono.fetch(event.request) }) - .add('itty-router', async () => { + bench('itty-router', async () => { await ittyRouter.handle(event.request) }) - .add('sunder', async () => { + bench('sunder', async () => { await sunderApp.handle(event) }) - .add('worktop', async () => { + bench('worktop', async () => { await worktopRouter.run(event) }) - .on('cycle', (event) => { - console.log(String(event.target)) - }) - .on('complete', function () { - console.log(`Fastest is ${this.filter('fastest').map('name')}`) - }) - .run({ async: true }) +}) + +run() diff --git a/benchmarks/handle-event/package.json b/benchmarks/handle-event/package.json index 3f2169b52..2b5b778e4 100644 --- a/benchmarks/handle-event/package.json +++ b/benchmarks/handle-event/package.json @@ -11,11 +11,11 @@ "author": "Yusuke Wada (https://github.com/yusukebe)", "license": "MIT", "devDependencies": { - "benchmark": "^2.1.4", "edge-mock": "^0.0.15", "itty-router": "^3.0.11", "node-fetch": "^3.2.10", "sunder": "^0.10.1", - "worktop": "^0.7.3" + "worktop": "^0.7.3", + "mitata": "^1.0.23" } -} \ No newline at end of file +} diff --git a/benchmarks/handle-event/yarn.lock b/benchmarks/handle-event/yarn.lock index 553d104ca..885b55512 100644 --- a/benchmarks/handle-event/yarn.lock +++ b/benchmarks/handle-event/yarn.lock @@ -28,14 +28,6 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== -benchmark@^2.1.4: - version "2.1.4" - resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629" - integrity sha512-l9MlfN4M1K/H2fbhfMy3B7vJd6AGKJVQn2h6Sg/Yx+KckoUA7ewS5Vv6TjSq18ooE1kS9hhAlQRH3AkXIh/aOQ== - dependencies: - lodash "^4.17.4" - platform "^1.3.3" - binary-extensions@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" @@ -365,11 +357,6 @@ livereload@^0.9.3: opts ">= 1.2.0" ws "^7.4.3" -lodash@^4.17.4: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - media-typer@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" @@ -402,6 +389,11 @@ mime@1.6.0: resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== +mitata@^1.0.23: + version "1.0.23" + resolved "https://registry.yarnpkg.com/mitata/-/mitata-1.0.23.tgz#aa2f9ec90c66b74ed3329889918bbe0ee0336d9f" + integrity sha512-G2t4HG01WGOceXNSq72IARFURXQh/9lNDdnxIfGHGHO31LTrpHuzRrZwoRqMgvgnF4uo0Cjo6SNMP8XGSbttCg== + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -480,11 +472,6 @@ picomatch@^2.0.4, picomatch@^2.2.1: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== -platform@^1.3.3: - version "1.3.6" - resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.6.tgz#48b4ce983164b209c2d45a107adb31f473a6e7a7" - integrity sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg== - proxy-addr@~2.0.7: version "2.0.7" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025"