1
1
import type { ContinuousThreadCpuProfile , ThreadCpuProfile } from '@sentry/core' ;
2
2
import { CpuProfilerBindings , PrivateCpuProfilerBindings } from '../src/cpu_profiler' ;
3
- import type { RawThreadCpuProfile } from '../src/types' ;
3
+ import { ProfileFormat , RawThreadCpuProfile } from '../src/types' ;
4
4
5
5
// Required because we test a hypothetical long profile
6
6
// and we cannot use advance timers as the c++ relies on
@@ -19,10 +19,10 @@ const fibonacci = (n: number): number => {
19
19
} ;
20
20
21
21
const wait = ( ms : number ) => new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
22
- const profiled = async ( name : string , fn : ( ) => void , format : 0 | 1 = 0 ) => {
22
+ const profiled = async ( name : string , fn : ( ) => void ) => {
23
23
CpuProfilerBindings . startProfiling ( name ) ;
24
24
await fn ( ) ;
25
- return CpuProfilerBindings . stopProfiling ( name , format ) ;
25
+ return CpuProfilerBindings . stopProfiling ( name , ProfileFormat . THREAD ) ;
26
26
} ;
27
27
28
28
const assertValidSamplesAndStacks = (
@@ -216,15 +216,15 @@ describe('Profiler bindings', () => {
216
216
} ) ;
217
217
218
218
it ( 'chunk format type' , async ( ) => {
219
- const profile = await profiled (
220
- 'non nullable stack' ,
221
- async ( ) => {
222
- await wait ( 1000 ) ;
223
- fibonacci ( 36 ) ;
224
- await wait ( 1000 ) ;
225
- } ,
226
- 1 ,
227
- ) ;
219
+ const fn = async ( ) => {
220
+ await wait ( 1000 ) ;
221
+ fibonacci ( 36 ) ;
222
+ await wait ( 1000 ) ;
223
+ } ;
224
+
225
+ CpuProfilerBindings . startProfiling ( 'non nullable stack' ) ;
226
+ await fn ( ) ;
227
+ const profile = CpuProfilerBindings . stopProfiling ( 'non nullable stack' , ProfileFormat . CHUNK ) ;
228
228
229
229
if ( ! profile ) fail ( 'Profile is null' ) ;
230
230
0 commit comments