Skip to content

Commit

Permalink
Add Benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Divjot Singh committed Nov 27, 2017
1 parent f5c017e commit b557ca0
Show file tree
Hide file tree
Showing 12 changed files with 17,407 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
.DS_Store
4 changes: 4 additions & 0 deletions benchmark/App.js

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Benchmark

The benchmark basically compares three servers.
* NodeJS (without streaming) - base case
* Marinate for NodeJS (without streaming) - this is to find overheard of using marinate
* Marinate for NodeJS (with streaming) - this is to see how well streaming performs.

The benchmark uses a test website created in [CSS Streaming](https://github.com/samccone/streaming-css).
This is no way close to a normal web app, however it is a good site to see benefits of streaming of CSS and HTML.

# Results

We performed LightHouse audit on these three servers.

| Case | Audit Result |
|:--|:--|
| Base Case | ![Raw static](raw-static.png) |
| Marinate w/o Streaming | ![Marinate without streaming](marinate-static.png)
| Marinate w/ Streaming | ![Marinate with streaming](marinate-stream.png)

| Case | First Meaning Paint | First Interactive
|:--|:--|:--|
| Base Case | 5080 ms | 15,310 ms
| Marinate w/o Streaming | 4950 ms | 15,020 ms
| Marinate w/ Streaming | 5020 ms | 14,550 ms


Binary file added benchmark/marinate-static.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmark/marinate-stream.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions benchmark/marinate_static.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const express = require('express')
const { createElement: h } = require('react')
const marinate = require('marinate')
const { renderToString } = require('react-dom/server')
const path = require('path')
const { readFileSync } = require('fs')

const App = require('./App')

const app = express()

const template = marinate`
<!doctype html>
<html>
<head>
<style>
${readFileSync(path.resolve(__dirname, 'style.css'), 'utf-8')}
</style>
</head>
<body>
${renderToString(h(App, null))}
</body>
</html>
`

app
.get('/', (req, res) => template(res))
.listen(1337, () => console.log('Server listening on port 1337'))


30 changes: 30 additions & 0 deletions benchmark/marinate_stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const express = require('express')
const { createElement: h } = require('react')
const marinate = require('marinate')
const { renderToNodeStream } = require('react-dom/server')
const path = require('path')
const { createReadStream } = require('fs')

const App = require('./App')

const app = express()

const template = marinate`
<!doctype html>
<html>
<head>
<style>
${() => createReadStream(path.resolve(__dirname, 'style.css'))}
</style>
</head>
<body>
${() => renderToNodeStream(h(App, null))}
</body>
</html>
`

app
.get('/', (req, res) => template(res))
.listen(1337, () => console.log('Server listening on port 1337'))


Loading

0 comments on commit b557ca0

Please sign in to comment.