Add perf matrix, esp for hybrid

This commit is contained in:
Pitchaya Boonsarngsuk
2018-02-12 08:53:54 +00:00
parent 0d148b555f
commit adf8126d86
3 changed files with 25 additions and 9 deletions

View File

@@ -200,7 +200,11 @@ function ticked() {
.attr("cy", function (d) { .attr("cy", function (d) {
return d.y*MULTIPLIER; return d.y*MULTIPLIER;
}); });
} }/*
if(alreadyRanIterations%10 != 1) stresses.push("");
else stresses.push(d3.calculateStress(nodes, function (n, m) {
return distanceFunction(n, m, props, norm);
}));*/
// Emit the distribution data to allow the drawing of the bar graph // Emit the distribution data to allow the drawing of the bar graph
if (springForce) { if (springForce) {
intercom.emit("passedData", simulation.force(forceName).distributionData()); intercom.emit("passedData", simulation.force(forceName).distributionData());
@@ -214,7 +218,7 @@ function ended() {
simulation.stop(); simulation.stop();
simulation.force(forceName, null); simulation.force(forceName, null);
console.log("ended"); console.log("ended");
if (rendering !== true) { // Never drawn anything before? Now it's time. //if (rendering !== true) { // Never drawn anything before? Now it's time.
node node
.attr("cx", function (d) { .attr("cx", function (d) {
return d.x*MULTIPLIER; return d.x*MULTIPLIER;
@@ -222,7 +226,10 @@ function ended() {
.attr("cy", function (d) { .attr("cy", function (d) {
return d.y*MULTIPLIER; return d.y*MULTIPLIER;
}); });
} //}
console.log("Post stress", d3.calculateStress(nodes, function (n, m) {
return distanceFunction(n, m, props, norm);
}));
if (p1 !== 0) { if (p1 !== 0) {
// Performance time measurement // Performance time measurement

View File

@@ -40,7 +40,8 @@ export default function (sim, forceS, forceF) {
initAlready = false, initAlready = false,
nodes, nodes,
alreadyRanIterations, alreadyRanIterations,
hybrid; hybrid,
p0 = performance.now(), p1, p2, p3;
if(simulation != undefined) initSimulation(); if(simulation != undefined) initSimulation();
if(forceS != undefined || forceF != undefined) initForces(); if(forceS != undefined || forceF != undefined) initForces();
@@ -105,14 +106,20 @@ export default function (sim, forceS, forceF) {
} }
function fullEnded() { function fullEnded() {
simulation.stop(); p3 = performance.now();
initAlready = false; simulation.stop();
simulation.force("Full force", null); initAlready = false;
event.call("end"); simulation.force("Full force", null);
} console.log("Phase 1 takes", p1-p0);
console.log("Phase 2 takes", p2-p1);
console.log("Phase 3 takes", p3-p2);
console.log("Total", p3-p0);
console.log("Phase 3 iterations", alreadyRanIterations);
event.call("end");
} }
function sampleEnded() { function sampleEnded() {
p1 = performance.now();
simulation.stop(); simulation.stop();
simulation.force("Sample force", null); simulation.force("Sample force", null);
// Reset velocity of all nodes // Reset velocity of all nodes
@@ -127,6 +134,7 @@ export default function (sim, forceS, forceF) {
} else { } else {
interpBruteForce(sample, remainder, interpDistanceFn, INTERP_FINE_ITS); interpBruteForce(sample, remainder, interpDistanceFn, INTERP_FINE_ITS);
} }
p2 = performance.now();
event.call("fullTick"); event.call("fullTick");
alreadyRanIterations = 0; alreadyRanIterations = 0;

View File

@@ -66,6 +66,7 @@ export default function () {
if(velocityDiff<stableVelocity){ if(velocityDiff<stableVelocity){
stableVeloHandler(); stableVeloHandler();
} }
else console.log(velocityDiff);
} }
} }