-
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (43 loc) 路 1.35 KB
/
Copy pathindex.js
File metadata and controls
47 lines (43 loc) 路 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { h } from 'preact';
import Suite from 'benchmarkjs-pretty';
import renderToStringBaseline, {
renderToStringAsync as renderToStringAsyncBaseline
} from 'baseline-rts';
// import renderToString from '../src/index';
import renderToString, { renderToStringAsync } from '../dist/index.module.js';
import TextApp from './text';
import StackApp from './stack';
import { App as IsomorphicSearchResults } from './isomorphic-ui/search-results/index';
import { App as ColorPicker } from './isomorphic-ui/color-picker';
function syncSuite(name, Root) {
return new Suite(name)
.add('baseline', () => renderToStringBaseline(<Root />))
.add('current', () => renderToString(<Root />))
.run();
}
function asyncSuite(name, Root) {
const suite = new Suite(name);
suite.suite.add(
'baseline',
function (deferred) {
renderToStringAsyncBaseline(<Root />).then(() => deferred.resolve());
},
{ defer: true }
);
suite.suite.add(
'current',
function (deferred) {
renderToStringAsync(<Root />).then(() => deferred.resolve());
},
{ defer: true }
);
return suite.run();
}
(async () => {
await syncSuite('Text', TextApp);
await syncSuite('SearchResults', IsomorphicSearchResults);
await syncSuite('ColorPicker', ColorPicker);
await syncSuite('Stack Depth', StackApp);
const { default: Async } = await import('./async.js');
await asyncSuite('async', Async);
})();