Skip to content

Commit

Permalink
Add time logger to example script.
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Jun 18, 2023
1 parent 8b05bce commit aa7eba1
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion examples/stp_to_obj.js
Original file line number Diff line number Diff line change
@@ -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 <stpFilePath> <objFilePath>');
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);
}

Expand Down Expand Up @@ -60,6 +83,7 @@ occtimportjs.then ((occt) => {
meshCount += 1;
vertexCount += meshVertexCount;
}
timeLogger.LogTime ('Obj export');

objWriter.close ();
});

0 comments on commit aa7eba1

Please sign in to comment.