Skip to content

Commit d61cbd4

Browse files
committed
Add back performance stories
1 parent 509a131 commit d61cbd4

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

examples/performance.story.tsx

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import { storiesOf } from "@storybook/react";
2+
import React from "react";
3+
import { RawDraftContentState } from "draft-js";
4+
import markovContentStates from "markov_draftjs";
5+
6+
import { DraftailEditor } from "../src/index";
7+
8+
import EditorBenchmark from "./components/EditorBenchmark";
9+
import { benchmarkProps } from "../tests/performance/MarkovBenchmark";
10+
11+
const contentStates = markovContentStates as RawDraftContentState[];
12+
13+
const NB_EDITORS = 50;
14+
const NB_EDITORS_LOW = 5;
15+
const MAX_EDITORS = contentStates.length;
16+
17+
const header = (
18+
<p>
19+
Enable the{" "}
20+
<a
21+
className="link"
22+
href="https://developers.google.com/web/tools/chrome-devtools/evaluate-performance/reference#fps-meter"
23+
>
24+
Chrome DevTools FPS meter
25+
</a>
26+
</p>
27+
);
28+
29+
storiesOf("Performance", module)
30+
.add(`markov_draftjs 41`, () => (
31+
<>
32+
{header}
33+
<EditorBenchmark
34+
componentProps={{
35+
rawContentState: contentStates[41],
36+
...benchmarkProps,
37+
}}
38+
runOnMount
39+
/>
40+
<DraftailEditor rawContentState={contentStates[41]} {...benchmarkProps} />
41+
</>
42+
))
43+
.add(`markov_draftjs 0-${NB_EDITORS_LOW}`, () => (
44+
<>
45+
{header}
46+
<>
47+
{contentStates.slice(0, NB_EDITORS_LOW).map((contentState, i) => (
48+
<DraftailEditor
49+
// eslint-disable-next-line react/no-array-index-key
50+
key={i}
51+
rawContentState={contentState}
52+
{...benchmarkProps}
53+
/>
54+
))}
55+
</>
56+
</>
57+
))
58+
.add(`markov_draftjs 0-${NB_EDITORS}`, () => (
59+
<>
60+
{header}
61+
<>
62+
{contentStates.slice(0, NB_EDITORS).map((contentState, i) => (
63+
<DraftailEditor
64+
// eslint-disable-next-line react/no-array-index-key
65+
key={i}
66+
rawContentState={contentState}
67+
{...benchmarkProps}
68+
/>
69+
))}
70+
</>
71+
</>
72+
))
73+
.add(`markov_draftjs ${MAX_EDITORS - NB_EDITORS_LOW}-${MAX_EDITORS}`, () => (
74+
<>
75+
{header}
76+
<>
77+
{contentStates.slice(-NB_EDITORS_LOW).map((contentState, i) => (
78+
<DraftailEditor
79+
// eslint-disable-next-line react/no-array-index-key
80+
key={i}
81+
rawContentState={contentState}
82+
{...benchmarkProps}
83+
/>
84+
))}
85+
</>
86+
</>
87+
))
88+
.add(`markov_draftjs ${MAX_EDITORS - NB_EDITORS}-${MAX_EDITORS}`, () => (
89+
<>
90+
{header}
91+
<>
92+
{contentStates.slice(-NB_EDITORS).map((contentState, i) => (
93+
<DraftailEditor
94+
// eslint-disable-next-line react/no-array-index-key
95+
key={i}
96+
rawContentState={contentState}
97+
{...benchmarkProps}
98+
/>
99+
))}
100+
</>
101+
</>
102+
));

0 commit comments

Comments
 (0)