From 6ba2383e2f57ca8ab201ae1a933613b0bd88ab3a Mon Sep 17 00:00:00 2001 From: hppeng Date: Sat, 16 Jul 2022 22:47:19 -0700 Subject: [PATCH] Add debugging printouts to skillpoint computation and overall compute --- js/builder.js | 5 +++++ js/builder_graph.js | 1 + js/computation_graph.js | 18 +++++++++++------- js/load.js | 1 - js/load_ing.js | 1 - js/skillpoints.js | 3 +++ 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/js/builder.js b/js/builder.js index 215ef22..e45c696 100644 --- a/js/builder.js +++ b/js/builder.js @@ -390,7 +390,12 @@ window.onerror = function(message, source, lineno, colno, error) { }; (async function() { + const start = Date.now(); let load_promises = [ load_init(), load_ing_init(), load_tome_init() ]; await Promise.all(load_promises); + const codestart = Date.now(); init(); + const end = Date.now(); + console.log(`builder calculation took ${(end-codestart)/ 1000} seconds.`); + console.log(`builder total took ${(end-start)/ 1000} seconds.`); })(); diff --git a/js/builder_graph.js b/js/builder_graph.js index f836986..dc52c1a 100644 --- a/js/builder_graph.js +++ b/js/builder_graph.js @@ -1143,5 +1143,6 @@ function builder_graph_init() { // this will propagate the update to the `stat_agg_node`, and then to damage calc console.log("Set up graph"); + let INPUT_UPDATE = true; } diff --git a/js/computation_graph.js b/js/computation_graph.js index 1f13851..d32554d 100644 --- a/js/computation_graph.js +++ b/js/computation_graph.js @@ -174,20 +174,24 @@ class ValueCheckComputeNode extends ComputeNode { } +let INPUT_UPDATE = false; + /** * Schedule a ComputeNode to be updated. * * @param node : ComputeNode to schedule an update for. */ function calcSchedule(node, timeout) { - if (node.update_task !== null) { - clearTimeout(node.update_task); + if (INPUT_UPDATE) { + if (node.update_task !== null) { + clearTimeout(node.update_task); + } + node.mark_dirty(); + node.update_task = setTimeout(function() { + node.update(); + node.update_task = null; + }, timeout); } - node.mark_dirty(); - node.update_task = setTimeout(function() { - node.update(); - node.update_task = null; - }, timeout); } class PrintNode extends ComputeNode { diff --git a/js/load.js b/js/load.js index c425c97..afdc85c 100644 --- a/js/load.js +++ b/js/load.js @@ -254,5 +254,4 @@ function init_maps() { redirectMap.set(item.id, item.remapID); } } - console.log(itemMap); } diff --git a/js/load_ing.js b/js/load_ing.js index ffc4c05..e5d37f4 100644 --- a/js/load_ing.js +++ b/js/load_ing.js @@ -232,5 +232,4 @@ function init_ing_maps() { recipeList.push(recipe["name"]); recipeIDMap.set(recipe["id"],recipe["name"]); } - console.log(ingMap); } diff --git a/js/skillpoints.js b/js/skillpoints.js index 5748a00..4c15a1d 100644 --- a/js/skillpoints.js +++ b/js/skillpoints.js @@ -1,4 +1,5 @@ function calculate_skillpoints(equipment, weapon) { + const start = Date.now(); // Calculate equipment equipping order and required skillpoints. // Return value: [equip_order, best_skillpoints, final_skillpoints, best_total]; let fixed = []; @@ -205,5 +206,7 @@ function calculate_skillpoints(equipment, weapon) { // best_skillpoints: manually assigned (before any gear) // final_skillpoints: final totals (5 individ) // best_total: total skillpoints assigned (number) + const end = Date.now(); + console.log(`skillpoint calculation took ${(end-start)/ 1000} seconds.`); return [equip_order, best_skillpoints, final_skillpoints, best_total, best_activeSetCounts]; }