-
Notifications
You must be signed in to change notification settings - Fork 184
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
Adding bottleneck vanilla test sites #803
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$blueish: blue; | ||
|
||
.blue-thing { | ||
background-color: $blueish; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$greenish: green; | ||
|
||
.green-thing { | ||
background-color: $greenish; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$indigoish: indigo; | ||
|
||
.indigo-thing { | ||
background-color: $indigoish; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$orangeish: orange; | ||
|
||
.orange-thing { | ||
background-color: $orangeish; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$purpleish: purple; | ||
|
||
.purple-thing { | ||
background-color: $purpleish; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$reddish: red; | ||
|
||
.red-thing { | ||
background-color: $reddish; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$yellowish: yellow; | ||
|
||
.yellow-thing { | ||
background-color: $yellowish; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {ReactServerAgent, RootContainer, RootElement} from "react-server"; | ||
import "./colors/red.scss"; | ||
import "./colors/green.scss"; | ||
|
||
const elements = []; | ||
/** | ||
* This page is a smoke test to determine whether or not the number of data requests in | ||
* a page is a performance bottleneck for react-server. It performs a thousand data | ||
* requests before returning a simple message. Metrics are created in the browser's console | ||
* related to performance metrics (see react-server.core.ClientController). | ||
*/ | ||
export default class DataRequestsPage { | ||
|
||
handleRoute() { | ||
//Reset elements, then perform one thousand local data requests before returning | ||
elements.length = 0; | ||
for (var i = 1; i <= 1000; i++) { | ||
let current = i; | ||
let promise = ReactServerAgent.get('/data/delay') | ||
.then(response => response.body); | ||
elements.push(<RootElement when={promise}><div>Data request {current} complete.</div></RootElement>); | ||
} | ||
return { code: 200 }; | ||
} | ||
|
||
getElements() { | ||
return [ | ||
<div className="red-thing">Data requests starting...</div>, | ||
<RootContainer> | ||
{elements} | ||
</RootContainer>, | ||
<div className="green-thing">Content should be above me.</div>, | ||
]; | ||
} | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import "./colors/red.scss"; | ||
import "./colors/blue.scss"; | ||
import "./colors/purple.scss"; | ||
import "./colors/green.scss"; | ||
import "./colors/orange.scss"; | ||
import "./colors/indigo.scss"; | ||
import "./colors/yellow.scss"; | ||
|
||
const RedThing = () => <div className="red-thing">This should be red</div>; | ||
const BlueThing = () => <div className="blue-thing">This should be blue</div>; | ||
const PurpleThing = () => <div className="purple-thing">This should be purple</div>; | ||
const GreenThing = () => <div className="green-thing">This should be green</div>; | ||
const OrangeThing = () => <div className="orange-thing">This should be orange</div>; | ||
const IndigoThing = () => <div className="indigo-thing">This should be indigo</div>; | ||
const YellowThing = () => <div className="yellow-thing">This should be yellow</div>; | ||
const ColorWheel = [RedThing(), BlueThing(), PurpleThing(), GreenThing(), | ||
OrangeThing(), IndigoThing(), YellowThing()]; | ||
const ColorSize = ColorWheel.length; | ||
|
||
/** | ||
* This page is a smoke test to determine whether or not the number of elements in | ||
* a page is a performance bottleneck for react-server. It returns a huge assortment of | ||
* randomly generated color-coded elements. Metrics are created in the browser's console | ||
* related to performance metrics (see react-server.core.ClientController). | ||
*/ | ||
export default class ElementsPage { | ||
|
||
getElements() { | ||
|
||
const colorThings = []; | ||
for (var i = 0; i < 10000; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After changing this behavior such that I was correctly returning a large number of elements (not one element with a large number of children), I found myself running out of heap space in javascript, so this number came down intentionally. |
||
// Select a random element from the colors of the rainbow | ||
let selection = Math.floor(Math.random() * ColorSize); | ||
colorThings.push(ColorWheel[selection]); | ||
}; | ||
|
||
return (colorThings); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to return a single element here with 100k children? Or 100k elements? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't appreciate the difference. I'm wanting 100k elements, so I'll adjust this accordingly. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import TestMiddleware from './test-middleware/TestMiddleware' | ||
import _ from "lodash"; | ||
|
||
/** | ||
* This page is a smoke test to determine whether or not the amount of middleware in | ||
* a page is a performance bottleneck for react-server. It has a middleware chain of | ||
* 1k copies of TestMiddleware, and the response is returned after this chain. | ||
* Note that all that is done within the middleware itself is a small string being appended | ||
* to the response. After the response is generated, the page is complete. | ||
*/ | ||
export default class MiddlewarePage { | ||
|
||
static middleware() { | ||
return _.range(1000).map(() => TestMiddleware); | ||
} | ||
|
||
getResponseData() { | ||
return ""; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export default class TestMiddleware { | ||
|
||
setConfigValues() { | ||
return { isRawResponse: true }; | ||
} | ||
|
||
getContentType() { | ||
return 'text/plain'; | ||
} | ||
|
||
handleRoute(next) { | ||
return next(); | ||
} | ||
|
||
getResponseData(next) { | ||
return next().then(data => data + "Middleware iteration succeeded.\r\n"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically I think we'd want the data requests to be kicked off in
handleRoute
. Practically, I'm not sure if that will make a difference.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, these should get kicked off in
handleRoute
, and then we should make root elements wait for them.Ideally we could style the root elements so they all fit above the fold and affect the WPT speed index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not incorporate this feedback into my most recent commit. I'll address this in the next commit.