polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
63 lines (62 loc) • 1.69 kB
JavaScript
export class PerformanceNode {
constructor(_node) {
this._node = _node;
this._cooks_count = 0;
this._total_cook_time = 0;
this._total_inputs_time = 0;
this._total_params_time = 0;
}
update_cook_data(performance_data) {
this._cooks_count += 1;
this._total_cook_time += performance_data.cook_time;
this._total_inputs_time += performance_data.inputs_time;
this._total_params_time += performance_data.params_time;
}
total_time() {
return this._total_cook_time + this._total_inputs_time + this._total_params_time;
}
total_cook_time() {
return this._total_cook_time;
}
cook_time_per_iteration() {
if (this._cooks_count > 0) {
return this._total_cook_time / this._cooks_count;
} else {
return 0;
}
}
total_inputs_time() {
return this._total_inputs_time;
}
inputs_time_per_iteration() {
if (this._cooks_count > 0) {
return this._total_inputs_time / this._cooks_count;
} else {
return 0;
}
}
total_params_time2() {
return this._total_params_time;
}
params_time_per_iteration2() {
if (this._cooks_count > 0) {
return this._total_params_time / this._cooks_count;
} else {
return 0;
}
}
cooks_count() {
return this._cooks_count;
}
print_object() {
return {
fullPath: this._node.fullPath(),
cooks_count: this.cooks_count(),
total_time: this.total_time(),
total_cook_time: this.total_cook_time(),
cook_time_per_iteration: this.cook_time_per_iteration(),
inputs_time_per_iteration: this.inputs_time_per_iteration(),
params_time_per_iteration: this.params_time_per_iteration2()
};
}
}