|
1 | 1 | # react-redux-benchmarks
|
| 2 | + |
2 | 3 | Performance benchmark harness for React-Redux
|
3 | 4 |
|
4 | 5 | This repo expects that you are using Yarn for package management.
|
5 | 6 |
|
6 | 7 | # Running benchmarks
|
| 8 | + |
7 | 9 | ```bash
|
8 |
| -yarn initialize |
| 10 | +yarn build |
9 | 11 | yarn start
|
10 | 12 | ```
|
11 | 13 |
|
12 |
| -After benchmarks have been initialized, you can run with simply: |
| 14 | +After benchmarks have been built, you can run with simply: |
13 | 15 |
|
14 | 16 | ```bash
|
15 | 17 | yarn start
|
16 | 18 | ```
|
17 | 19 |
|
18 |
| -## Running specific versions |
| 20 | +You'll need to rebuild the benchmarks after every code change. |
| 21 | + |
| 22 | +## Running specific versions of react-redux |
19 | 23 |
|
20 | 24 | To specify a single version:
|
21 | 25 |
|
22 | 26 | ```bash
|
23 |
| -REDUX=5.0.7 yarn start |
| 27 | +yarn start --versions 8.1.1 |
| 28 | +yarn start -v 8.1.1 |
24 | 29 | ```
|
25 | 30 |
|
26 | 31 | To specify running against multiple versions:
|
27 | 32 |
|
28 | 33 | ```bash
|
29 |
| -REDUX=5.0.7:4.4.9 yarn start |
| 34 | +yarn start -v 8.1.1 7.2.5 |
30 | 35 | ```
|
31 | 36 |
|
32 |
| -To run a specific benchmark: |
| 37 | +## To run a specific benchmark: |
33 | 38 |
|
34 | 39 | ```bash
|
35 |
| -BENCHMARKS=stockticker yarn start |
| 40 | +yarn start --scenarios deeptree |
| 41 | +yarn start -s deeptree |
36 | 42 | ```
|
37 | 43 |
|
38 | 44 | or specific benchmarks:
|
39 | 45 |
|
40 | 46 | ```bash
|
41 |
| -BENCHMARKS=stockticker:another yarn start |
| 47 | +yarn start -s deeptree forms |
42 | 48 | ```
|
43 | 49 |
|
44 | 50 | ## Setting run length
|
45 | 51 |
|
46 | 52 | By default, benchmarks run for 30 seconds. To change this, use
|
47 | 53 |
|
48 | 54 | ```bash
|
49 |
| -SECONDS=10 yarn start |
| 55 | +yarn start --length 5 |
| 56 | +yarn start -l 5 |
50 | 57 | ```
|
51 | 58 |
|
52 |
| - |
53 | 59 | # Adding a benchmark
|
54 | 60 |
|
55 |
| -Benchmarks live in the `sources/` directory. Each benchmark must insert this |
56 |
| -code into `index.js`: |
57 |
| - |
58 |
| -```js |
59 |
| -import 'fps-emit' |
60 |
| -``` |
61 |
| - |
62 |
| -In addition, a `config-overrides.js` must be created with these contents: |
| 61 | +Benchmarks live in the `src/scenarios` directory. Each benchmark must render a React component like this: |
63 | 62 |
|
64 | 63 | ```js
|
65 |
| -module.exports = function override(config, env) { |
66 |
| - //do stuff with the webpack config... |
67 |
| - console.log(`Environment: ${env}`) |
68 |
| - |
69 |
| - if(env === "production") { |
70 |
| - config.externals = { |
71 |
| - "react" : "React", |
72 |
| - "redux" : "Redux", |
73 |
| - "react-redux" : "ReactRedux", |
74 |
| - } |
75 |
| - } |
76 |
| - |
77 |
| - |
78 |
| - return config; |
79 |
| -} |
80 |
| -``` |
81 |
| - |
82 |
| -and the scripts section of `package.json` should be changed to: |
83 |
| - |
84 |
| -```json |
85 |
| - "scripts": { |
86 |
| - "start": "react-app-rewired start", |
87 |
| - "build": "react-app-rewired build", |
88 |
| - "test": "react-app-rewired --env=jsdom", |
89 |
| - ... |
90 |
| - } |
91 |
| -``` |
92 |
| - |
93 |
| -Also, `index.html` must be modified to include these lines: |
| 64 | +import { renderApp } from '../../common' |
94 | 65 |
|
95 |
| -```html |
96 |
| - <script type="text/javascript" src="redux.min.js"></script> |
97 |
| - <script type="text/javascript" src="react.production.min.js"></script> |
98 |
| - <script type="text/javascript" src="react-dom.production.min.js"></script> |
99 |
| - <script type="text/javascript" src="react-redux.min.js"></script> |
| 66 | +renderApp(<App />, store) |
100 | 67 | ```
|
101 | 68 |
|
| 69 | +Where `App` is your benchmark component, and `store` is your redux store. |
102 | 70 |
|
103 | 71 | If you need to make changes to the `fps-emit` package, bump the version number in its `package.json`,
|
104 | 72 | then update each benchmark to use the newest version using `yarn upgrade-interactive` and selecting `fps-emit`
|
105 |
| -for an update. Then rebuild all the benchmarks using `yarn initialize` |
| 73 | +for an update. Then rebuild all the benchmarks using `yarn build` |
0 commit comments