From aa7eba10bc06b7cd65ec0fd3eb1ee07b198123ef Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sun, 18 Jun 2023 17:17:05 +0200 Subject: [PATCH] Add time logger to example script. --- examples/stp_to_obj.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/examples/stp_to_obj.js b/examples/stp_to_obj.js index 639722e..9f6f9a7 100644 --- a/examples/stp_to_obj.js +++ b/examples/stp_to_obj.js @@ -1,18 +1,41 @@ let fs = require ('fs'); const occtimportjs = require ('../dist/occt-import-js.js')(); +class TimeLogger +{ + constructor () + { + this.beginDate = new Date (); + } + + LogTime (message) + { + let currentDate = new Date (); + console.log (message + ': ' + (currentDate - this.beginDate).toString ()); + this.beginDate = currentDate; + } +} + let args = process.argv.splice (2); if (args.length !== 2) { + console.log ('Usage: node stp_to_obj.js '); process.exit (1); } let stpFilePath = args[0]; let objFilePath = args[1]; +let timeLogger = new TimeLogger (); occtimportjs.then ((occt) => { + timeLogger.LogTime ('Library load'); + let fileContent = fs.readFileSync (stpFilePath); + timeLogger.LogTime ('File read'); + let stpContent = occt.ReadStepFile (fileContent, null); - if (!stpContent.success) { + timeLogger.LogTime ('Step import'); + + if (!stpContent.success) { process.exit (1); } @@ -60,6 +83,7 @@ occtimportjs.then ((occt) => { meshCount += 1; vertexCount += meshVertexCount; } + timeLogger.LogTime ('Obj export'); objWriter.close (); });