-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c8727d
commit 86e94fe
Showing
7 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react' | ||
|
||
export default function Root({ children }) { | ||
return ( | ||
<html> | ||
<head></head> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as React from 'react' | ||
|
||
export default function page() { | ||
return <div>hello</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "stats-app", | ||
"private": true, | ||
"license": "MIT", | ||
"dependencies": { | ||
"webpack-bundle-analyzer": "^4.6.1", | ||
"webpack-stats-plugin": "^1.1.0" | ||
}, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as React from 'react' | ||
|
||
export default function page() { | ||
return <div> hello world </div> | ||
} | ||
|
||
export async function getServerSideProps() { | ||
return {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "next-minimal-server", | ||
"description": "Minimal server for Next.js for benchmarking/perf analysis purposes.", | ||
"scripts": { | ||
"start": "node start.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
process.env.__NEXT_REACT_CHANNEL = 'exp' | ||
process.env.NODE_ENV = 'production' | ||
|
||
require('../../test/lib/react-channel-require-hook') | ||
|
||
console.time('next-cold-start') | ||
const NextServer = require('next/dist/server/next-server').default | ||
const path = require('path') | ||
|
||
const appDir = path.join(__dirname, 'benchmark-app') | ||
const distDir = '.next' | ||
|
||
const compiledConfig = require(path.join( | ||
appDir, | ||
distDir, | ||
'required-server-files.json' | ||
)).config | ||
|
||
process.chdir(appDir) | ||
|
||
const nextServer = new NextServer({ | ||
conf: compiledConfig, | ||
dir: appDir, | ||
distDir, | ||
minimalMode: true, | ||
customServer: false, | ||
}) | ||
|
||
const requestHandler = nextServer.getRequestHandler() | ||
|
||
require('http') | ||
.createServer((req, res) => { | ||
console.time('next-request') | ||
return requestHandler(req, res).finally(() => { | ||
console.timeEnd('next-request') | ||
}) | ||
}) | ||
.listen(3000, () => { | ||
console.timeEnd('next-cold-start') | ||
}) |