├── .gitignore ├── LICENSE ├── README.md ├── html └── index.html ├── js └── main.js ├── package.json └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | node_modules 4 | 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Axel Rauschmayer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |  2 | 3 | # Run 4 | 5 | * Build once: `npm run webpack` 6 | * Run dev server: `npm start` 7 | * Web page: http://localhost:8080/ 8 | * Open the console 9 | * Run `window.benchmark()` 10 | 11 | 12 | Built using https://github.com/rauschma/react-starter-project 13 | -------------------------------------------------------------------------------- /html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 |window.benchmark(10)
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/js/main.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {render} from 'react-dom';
3 |
4 | const Dot = (props) =>
5 | .;
6 |
7 | class DotComponent extends React.Component {
8 | render() {
9 | return .;
10 | }
11 | }
12 |
13 | class Main extends React.Component {
14 | render() {
15 | var dots = Array(500).fill(0).map(x => {
16 | if(this.props.kind == 'stateless-functional-direct-call') {
17 | return Dot();
18 | } else if(this.props.kind == 'stateless-functional-mounted') {
19 | return React.createElement(Dot, {}, {});
20 | } else if(this.props.kind == 'stateful') {
21 | return React.createElement(DotComponent, {}, {});
22 | }
23 | })
24 | return React.createElement('div', {}, ...dots);
25 | }
26 | }
27 |
28 | let prevBenchmarkTime, benchmarkCount, statefulTotalTime, statelessFunctionalMountedTotalTime, statelessFunctionalDirectCallTotalTime;
29 | benchmarkCount = 0;
30 | statefulTotalTime = 0;
31 | statelessFunctionalMountedTotalTime = 0;
32 | statelessFunctionalDirectCallTotalTime = 0;
33 |
34 | const run = () => {
35 | ['stateful', 'stateless-functional-mounted', 'stateless-functional-direct-call'].forEach(kind => {
36 | const prevTime = performance.now();
37 |
38 | var items = [];
39 | var i, len;
40 | for (i = 0, len = 20; i < len; i++) {
41 | items.push(i);
42 | }
43 | items.forEach(i => {
44 | render((
45 |