redoc/perf/index.tsx

28 lines
790 B
TypeScript
Raw Normal View History

2017-10-12 00:01:37 +03:00
import * as React from 'react';
import { render } from 'react-dom';
import { Redoc, RedocProps } from '../src/components';
import { AppStore } from '../src/services/AppStore';
2017-11-19 23:11:40 +03:00
import { loadAndBundleSpec } from '../src/utils';
2017-10-12 00:01:37 +03:00
const renderRoot = (Component: typeof Redoc, props: RedocProps) =>
2017-11-19 23:11:40 +03:00
render(<Component {...props} />, document.getElementById('example'));
2017-10-12 00:01:37 +03:00
2017-11-19 23:11:40 +03:00
async function start() {
const resolvedSpec = await loadAndBundleSpec('big-openapi.json');
2017-10-12 00:01:37 +03:00
const t0 = performance.now();
2017-11-19 23:11:40 +03:00
const store = new AppStore(resolvedSpec, 'big-openapi.json');
2017-10-12 00:01:37 +03:00
var t1 = performance.now();
2017-11-19 23:11:40 +03:00
renderRoot(Redoc, { store });
var t2 = performance.now();
console.log({
timings: true,
'Total Time': t2 - t0,
'Store Init Time': t1 - t0,
'Render Time': t2 - t1,
});
}
start();