MCPcopy Create free account
hub / github.com/ThatOpen/engine_web-ifc / BenchmarkIfcFile

Function BenchmarkIfcFile

tests/benchmark/benchmark.ts:138–179  ·  view source on GitHub ↗
(module: any, filename: string)

Source from the content-addressed store, hash-verified

136}
137
138async function BenchmarkIfcFile(module: any, filename: string): Promise<FileResult>
139{
140 let result = new FileResult();
141 result.filename = filename;
142
143 const ifcFilePath = path.join(filename);
144 let ifcFileContent;
145 if (filename.includes(".ifczip")) {
146 let zip = new AdmZip(filename);
147 zip.getEntries().forEach(function (zipEntry:any) {
148 ifcFileContent = zipEntry.getData();
149 });
150 } else ifcFileContent = await StreamFileToString(ifcFilePath);
151
152 let startTime = ms();
153 let modelID : number = module.OpenModel(ifcFileContent);
154 let endTime = ms();
155 result.timeTakenToOpenModel = endTime - startTime; // time to open and close the file and nothing else
156
157 startTime = ms();
158 result.numberOfIfcEntities = module.GetAllLines(modelID).size();
159
160 result.totalNumberOfProducedMesh = 0;
161 module.StreamAllMeshes(modelID, () => {
162 ++result.totalNumberOfProducedMesh;
163 });
164
165 result.totalNumberOfGeometries = module.LoadAllGeometry(modelID).size();
166 let stats = fs.statSync(ifcFilePath);
167 let fileSizeInBytes = stats.size;
168 // Convert the file size to megabytes (optional)
169 let sizeMo = fileSizeInBytes / (1024*1024);
170 result.fileSize = parseFloat(sizeMo.toFixed(2));
171 module.CloseModel(modelID);
172
173
174 endTime = ms();
175 result.timeSuccess = endTime - startTime;
176 console.log(`Parsed model ${result.filename} in ${result.timeTakenToOpenModel} ms`);
177
178 return result;
179}
180
181async function BenchmarkWebIFC(module: any, files: string[]): Promise<BenchMarkResult>
182{

Callers 1

BenchmarkWebIFCFunction · 0.85

Calls 8

StreamFileToStringFunction · 0.85
OpenModelMethod · 0.80
sizeMethod · 0.80
StreamAllMeshesMethod · 0.80
msFunction · 0.70
GetAllLinesMethod · 0.45
LoadAllGeometryMethod · 0.45
CloseModelMethod · 0.45

Tested by

no test coverage detected