@@ -88,6 +88,27 @@ class BenchmarkResultFormatter{
8888 }
8989}
9090
91+ async function StreamFileToString ( filename : string ) {
92+ let stream = fs . createReadStream ( filename ) ;
93+ return new Promise ( ( resolve , reject ) => {
94+ const data :any = [ ] ;
95+
96+ stream . on ( 'data' , ( chunk ) => {
97+ data . push ( chunk ) ;
98+ } ) ;
99+
100+ stream . on ( 'end' , ( ) => {
101+ resolve ( Buffer . concat ( data ) )
102+ } )
103+
104+ stream . on ( 'error' , ( err ) => {
105+ reject ( err )
106+ } )
107+
108+ return data ;
109+ } )
110+ }
111+
91112async function BenchmarkIfcFile ( module : any , filename : string ) : Promise < FileResult >
92113{
93114 let result = new FileResult ( ) ;
@@ -97,7 +118,7 @@ async function BenchmarkIfcFile(module: any, filename: string): Promise<FileResu
97118 //let modelID = module.OpenModel("example.ifc", new Uint8Array(data.toString()));
98119
99120 const ifcFilePath = path . join ( __dirname , './' + filename ) ;
100- const ifcFileContent = fs . readFileSync ( ifcFilePath ) ;
121+ const ifcFileContent = await StreamFileToString ( ifcFilePath ) ;
101122
102123 let startTime = ms ( ) ;
103124 let modelID : number = module . OpenModel ( ifcFileContent ) ;
@@ -176,7 +197,7 @@ function generateMarkdownReport(systemInfo : SystemInfo, fileResult : Map<string
176197 let formatter = new BenchmarkResultFormatter ( ) ;
177198 formatter . columns = {
178199 filename : "filename" ,
179- fileSize : "Size (mo )" ,
200+ fileSize : "Size (mb )" ,
180201 timeTakenToOpenModel : "Time to open model (ms)" ,
181202 timeSuccess : "Time to execute all (ms)" ,
182203 numberOfIfcEntities : "Total ifc entities" ,
0 commit comments