mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add benchmarks for server rendering (#1294)
* Add benchmarks for server rendering * Remove bench from flyfile
This commit is contained in:
parent
b37431461d
commit
ebb397975d
|
@ -1,32 +0,0 @@
|
|||
|
||||
import { resolve } from 'path'
|
||||
import build from '../server/build'
|
||||
import { render as _render } from '../server/render'
|
||||
import Benchmark from 'benchmark'
|
||||
|
||||
const dir = resolve(__dirname, 'fixtures', 'basic')
|
||||
const suite = new Benchmark.Suite('Next.js')
|
||||
|
||||
suite
|
||||
.on('start', async () => build(dir))
|
||||
|
||||
.add('Tiny stateless component', async p => {
|
||||
await render('/stateless')
|
||||
p.resolve()
|
||||
}, { defer: true })
|
||||
|
||||
.add('Big stateless component', async p => {
|
||||
await render('/stateless-big')
|
||||
p.resolve()
|
||||
}, { defer: true })
|
||||
|
||||
.add('Stateful component with a loooot of css', async p => {
|
||||
await render('/css')
|
||||
p.resolve()
|
||||
}, { defer: true })
|
||||
|
||||
module.exports = suite
|
||||
|
||||
function render (url, ctx) {
|
||||
return _render(url, ctx, { dir, staticMarkup: true })
|
||||
}
|
9
bench/package.json
Normal file
9
bench/package.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "next-bench",
|
||||
"scripts": {
|
||||
"build": "next build",
|
||||
"start": "npm run build && next start",
|
||||
"bench:stateless": "ab -c1 -n3000 http://0.0.0.0:3000/stateless",
|
||||
"bench:stateless-big": "ab -c1 -n500 http://0.0.0.0:3000/stateless-big"
|
||||
}
|
||||
}
|
|
@ -1,3 +1 @@
|
|||
import React from 'react'
|
||||
|
||||
export default () => <h1>My component!</h1>
|
27
bench/readme.md
Normal file
27
bench/readme.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Next.js server-side benchmarks
|
||||
|
||||
## Installation
|
||||
|
||||
Follow the steps in [contributing.md](../contributing.md)
|
||||
|
||||
Both benchmarks use `ab`. So make sure you have that installed.
|
||||
|
||||
## Usage
|
||||
|
||||
Before running the test:
|
||||
|
||||
```
|
||||
npm run start
|
||||
```
|
||||
|
||||
Then run one of these tests:
|
||||
|
||||
- Stateless application which renders `<h1>My component!</h1>`. Runs 3000 http requests.
|
||||
```
|
||||
npm run bench:stateless
|
||||
```
|
||||
|
||||
- Stateless application which renders `<li>This is row {i}</li>` 10.000 times. Runs 500 http requests.
|
||||
```
|
||||
npm run bench:stateless-big
|
||||
```
|
12
flyfile.js
12
flyfile.js
|
@ -44,18 +44,6 @@ export async function build(fly) {
|
|||
await fly.serial(['copy', 'compile'])
|
||||
}
|
||||
|
||||
export async function bench(fly) {
|
||||
await fly.parallel(['compile', 'copy'])
|
||||
// copy bench fixtures
|
||||
await fly.source('bench/fixtures/**/*').target('dist/bench/fixtures')
|
||||
// compile bench
|
||||
await fly.source('bench/*.js').babel().target('dist/bench')
|
||||
notify('Compiled bench files')
|
||||
// yield fly.source('dist/bench/*.js').benchmark({
|
||||
// benchmark.reporters.etalon('RegExp#test')
|
||||
// })
|
||||
}
|
||||
|
||||
export default async function (fly) {
|
||||
await fly.start('build')
|
||||
await fly.watch('bin/*', 'bin')
|
||||
|
|
Loading…
Reference in a new issue