From cf923c6b25f59e809b6638ce5b303949f102726f Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 7 Nov 2020 19:57:11 -0500 Subject: [PATCH] add render stats. remove dead code --- src/kiri/main.js | 20 ++++----- src/kiri/render.js | 12 +++++ src/kiri/slice.js | 101 +----------------------------------------- src/kiri/widget.js | 6 +-- src/mode/fdm/slice.js | 2 + 5 files changed, 28 insertions(+), 113 deletions(-) diff --git a/src/kiri/main.js b/src/kiri/main.js index 7633c248..c3c4dd5c 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -841,18 +841,11 @@ widget.setColor(color.slicing); widget.slice(settings, function(sliced, error) { let mark = UTIL.time(); - // on done - widget.render(); - // clear wireframe - widget.setWireframe(false, color.wireframe, color.wireframe_opacity); - widget.setOpacity(camOrLaser ? color.cam_sliced_opacity : color.sliced_opacity); - widget.setColor(color.deselected); // update UI info if (sliced) { // update segment time - if (lastMsg) segtimes[segNumber+"_"+lastMsg] = mark - startTime; + if (lastMsg) segtimes[`${segNumber++}_${lastMsg}`] = mark - startTime; segtimes.total = UTIL.time() - now; - DBUG.log(segtimes); API.event.emit('slice', getMode()); updateSliderMax(true); if (preserveMax != API.var.layer_max) { @@ -860,12 +853,20 @@ } firstMesh = false; } + // on done + segtimes[`${segNumber}_draw`] = widget.render(); + // clear wireframe + widget.setWireframe(false, color.wireframe, color.wireframe_opacity); + widget.setOpacity(camOrLaser ? color.cam_sliced_opacity : color.sliced_opacity); + widget.setColor(color.deselected); // on the last exit, update ui and call the callback if (--countdown === 0 || error || errored) { API.show.progress(0); showSlices(preserveLayer); SPACE.scene.active(); API.event.emit('slice.end', getMode()); + // print stats + DBUG.log(segtimes); if (callback && typeof callback === 'function') { callback(); } @@ -881,10 +882,9 @@ }, function(update, msg) { if (msg !== lastMsg) { let mark = UTIL.time(); - if (lastMsg) segtimes[segNumber+"_"+lastMsg] = mark - startTime; + if (lastMsg) segtimes[`${segNumber++}_${lastMsg}`] = mark - startTime; lastMsg = msg; startTime = mark; - segNumber++; } // on update track[widget.id] = update; diff --git a/src/kiri/render.js b/src/kiri/render.js index e6441e1d..540c6891 100644 --- a/src/kiri/render.js +++ b/src/kiri/render.js @@ -9,6 +9,13 @@ constructor() { this.layers = {}; this.profiles = {}; + this.stats = { + contour: 0, + flat_line: 0, + flat_poly: 0, + line_poly: 0, + line: 0 + }; } setLayer(layer, colors) { @@ -53,6 +60,7 @@ } for (let i=0; i { this.addTop(p); @@ -192,85 +172,6 @@ return top; }; - /** - * Returns all top polygons as an array - * - * @param {Polygon[]} out array to populate - * @returns {Polygon[]} array of top polygons - */ - // PRO.gatherTopPolys = function(out) { - // this.tops.forEach(function(top) { - // out.push(top.poly); - // }); - // return out; - // }; - - /** - * Appends all inner trace inner polygons (holes) - * into a given array and returns it - * - * @param {Polygon[]} out array to populate - * @returns {Polygon[]} array of top polygons - */ - // PRO.gatherTopPolyInners = function(out) { - // this.tops.forEach(function(top) { - // if (top.poly.inner) out.appendAll(top.poly.inner); - // }); - // return out; - // }; - - /** - * Appends all trace polygons into a given array and returns it - * - * @param {Polygon[]} out array to populate - * @returns {Polygon[]} array of top polygons - */ - // PRO.gatherTraces = function(out) { - // this.tops.forEach(function(top) { - // out.appendAll(top.traces); - // }); - // return out; - // }; - - /** - * Appends all innermost trace polygons into a given array and returns it - * - * @param {Polygon[]} out array to populate - * @returns {Polygon[]} array of top polygons - */ - // PRO.gatherInner = function(out) { - // this.tops.forEach(function(top) { - // out.appendAll(top.inner); - // }); - // return out; - // }; - - /** - * Appends all solid area polygons into a given array and returns it - * - * @param {Polygon[]} out array to populate - * @returns {Polygon[]} array of top polygons - */ - // PRO.gatherSolids = function(out) { - // this.tops.forEach(function(top) { - // out.appendAll(top.solids); - // }); - // return out; - // }; - - /** - * return all fill lines. includes points for solid layers, - * solid polygon regions and support line polygons. - * - * @param {Point[]} [lines] array to append to - */ - // PRO.gatherFillLines = function(lines) { - // this.tops.forEach(function(top) { - // if (top.fill_lines) lines.appendAll(top.fill_lines); - // }); - // return lines; - // }; - function newTop(poly) { return new Top(poly); } diff --git a/src/kiri/widget.js b/src/kiri/widget.js index 5ce36972..7c118254 100644 --- a/src/kiri/widget.js +++ b/src/kiri/widget.js @@ -594,7 +594,7 @@ return ondone(error); } - onupdate(1.0, "transferring"); + onupdate(1.0, "transfer"); widget.stats.slice_time = UTIL.time() - startTime; widget.modified = false; @@ -627,9 +627,9 @@ * render all slice and processed data */ PRO.render = function() { - let mark = Date.now(); + const mark = Date.now(); DRIVERS[this.settings.mode.toUpperCase()].sliceRender(this); - if (KIRI.api.const.LOCAL) console.log({sliceRender: Date.now() - mark}); + return Date.now() - mark; }; PRO.hideSlices = function() { diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index 08b52936..4625081d 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -469,6 +469,8 @@ // .setLayer("flats", { face: 0xaa00aa, line: 0xaa00aa }) // .addAreas(top.flats); // } + + // console.log(slice.index, slice.render.stats); } /**