File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { TabixIndexedFile } from './esm/index.js'
2+ import { fileURLToPath } from 'url'
3+ import { dirname , join } from 'path'
4+ import inspector from 'inspector'
5+ import fs from 'fs'
6+
7+ const __dirname = dirname ( fileURLToPath ( import . meta. url ) )
8+
9+ async function runBenchmark ( ) {
10+ const f = new TabixIndexedFile ( {
11+ path : join ( __dirname , 'test/data/1kg.chr1.subset.vcf.gz' ) ,
12+ } )
13+
14+ let totalLines = 0
15+ const iterations = 100
16+
17+ const session = new inspector . Session ( )
18+ session . connect ( )
19+
20+ session . post ( 'Profiler.enable' , ( ) => {
21+ session . post ( 'Profiler.start' , async ( ) => {
22+ for ( let iter = 0 ; iter < iterations ; iter ++ ) {
23+ let count = 0
24+ await f . getLines ( 'chr1' , 10109 , 11000 , ( ) => {
25+ count ++
26+ } )
27+ totalLines += count
28+ }
29+
30+ console . log ( `Total lines processed: ${ totalLines } ` )
31+
32+ session . post ( 'Profiler.stop' , ( err , { profile } ) => {
33+ if ( ! err ) {
34+ fs . writeFileSync ( 'profile.cpuprofile' , JSON . stringify ( profile ) )
35+ console . log ( 'CPU profile written to profile.cpuprofile' )
36+ console . log ( 'View with: npx speedscope profile.cpuprofile' )
37+ }
38+ session . disconnect ( )
39+ } )
40+ } )
41+ } )
42+ }
43+
44+ runBenchmark ( ) . catch ( console . error )
You can’t perform that action at this time.
0 commit comments