-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #867 from krisxw/master
Adding large data request site to provide additional testing for 866
- Loading branch information
Showing
2 changed files
with
40 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
36 changes: 36 additions & 0 deletions
36
packages/react-server-test-pages/pages/bottleneck/largeDataRequests.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,36 @@ | ||
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 large data requests in | ||
* a page are a performance bottleneck for react-server. It performs a hundred large 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 LargeDataRequestsPage { | ||
|
||
handleRoute() { | ||
//Reset elements, then perform one hundred large, local data requests before returning | ||
elements.length = 0; | ||
for (var i = 1; i <= 100; i++) { | ||
let current = i; | ||
let promise = ReactServerAgent.get('/data/delay') | ||
.query({ big: 10000 }) | ||
.then(response => response.body); | ||
elements.push(<RootElement when={promise}><div>10K Data request number {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>, | ||
]; | ||
} | ||
} |