1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import benchmarkjs from 'benchmark';
- import {initializeLocale} from 'sentry/bootstrap/initializeLocale';
- import eventedTrace from './formats/android/trace.json';
- import sampledTrace from './formats/ios/trace.json';
- import jsSelfProfileTrace from './formats/jsSelfProfile/trace.json';
- import nodeTrace from './formats/node/trace.json';
- import typescriptTrace from './formats/typescript/trace.json';
- import {importProfile} from './importProfile';
- initializeLocale({} as any);
- import * as Sentry from '@sentry/node';
- import '@sentry/tracing';
- import {ProfilingIntegration} from '@sentry/profiling-node';
- if (process.env.PROFILE) {
- Sentry.init({
- dsn: 'https://7fa19397baaf433f919fbe02228d5470@o1137848.ingest.sentry.io/6625302',
- integrations: [
-
- new ProfilingIntegration(),
- ],
- debug: true,
- tracesSampleRate: 1.0,
-
- profilesSampleRate: 1.0,
- });
- }
- function benchmark(name: string, callback: () => void) {
- const suite = new benchmarkjs.Suite();
- suite
- .add(name, callback, {minSamples: 50})
- .on('cycle', event => {
-
-
- console.log(event.target.toString(), (event.target.stats.mean * 1e3).toFixed(2));
- })
- .on('error', event => {
-
- throw event;
- })
- .on('fini');
- suite.run({async: true, minSamples: 100});
- }
- benchmark('typescript', () => importProfile(typescriptTrace as any, '', 'flamechart'));
- benchmark('js self profile', () =>
- importProfile(jsSelfProfileTrace as any, '', 'flamechart')
- );
- benchmark('evented profile', () => importProfile(eventedTrace as any, '', 'flamechart'));
- benchmark('sampled profile', () => importProfile(sampledTrace as any, '', 'flamechart'));
- benchmark('sampled node profile', () =>
- importProfile(nodeTrace as any, '', 'flamechart')
- );
|