Commit 68c3fd04 authored by marc's avatar marc

smartUpdate for everyone

-enable smartUpdate() as default update() method for all views
-remove some benchmark code (factorized in smartUpdate())
parent df9ea4bf
......@@ -24,6 +24,8 @@
function Builder(model, database) {
if (typeof model != "undefined"){
View.call(this, model);
this.type = "Builder";
this.useSmartUpdate = true;
}
if(typeof database != 'undefined') {
......
......@@ -74,7 +74,9 @@
* */
function Graph(id, model, database) {
//
View.call(this, model);
View.call(this, model);
this.type = "Graph";
this.useSmartUpdate = true;
this.id = id;
this.resizeW = 1; //coeff d'agrandissement/réduction largeur
......@@ -319,7 +321,7 @@ Graph.prototype = {
this.text_position_x = 60;
this.text_position_x2 = div_width - 60;
this.update(speed);
this.smartUpdate(speed);
},
/* ************************************************ *
......@@ -331,22 +333,11 @@ Graph.prototype = {
* */
update : function (speed) {
speed = typeof speed !== 'undefined' ? speed : 500;
var startTime = new Date()
.getTime();
var elapsedTime = 0;
this.initAxis()
.initData()
.updateRes()
.updateClones()
.draw(speed);
elapsedTime = new Date()
.getTime() - startTime;
// console.log("update Graph: " + elapsedTime + "ms");
return this
},
/* update resolution curves
......@@ -1381,7 +1372,7 @@ Graph.prototype = {
shouldRefresh: function() {
this.init();
this.update();
this.smartUpdate();
this.resize();
}
......
......@@ -23,6 +23,8 @@
function Info(id, model, builder) {
View.call(this, model);
this.type = "Info";
this.useSmartUpdate = true;
this.id = id;
this.builder = builder;
}
......
......@@ -46,6 +46,8 @@ function List(id_list, id_data, model, database) {
var self=this;
View.call(this, model);
this.type = "List";
this.useSmartUpdate = true;
this.db = database;
this.id = id_list; //ID de la div contenant la liste
......@@ -345,10 +347,7 @@ List.prototype = {
* update all content for list and data list
* */
update: function () {
var startTime = new Date()
.getTime();
var elapsedTime = 0;
var list = [];
for (var i = 0; i < this.m.clones.length; i++) {
list.push(i);
......@@ -356,10 +355,6 @@ List.prototype = {
this.updateElem(list);
this.update_data_list()
elapsedTime = new Date()
.getTime() - startTime;
//console.log("update List: " + elapsedTime + "ms");
//TODO check order
document.getElementById("list_sort_select").selectedIndex = 0;
},
......
......@@ -36,6 +36,8 @@ function ScatterPlot(id, model, database, default_preset) {
var self = this;
View.call(this, model);
this.type = "ScatterPlot";
this.useSmartUpdate = true;
this.db = database;
this.id = id; //ID of the scatterPlot div
......@@ -1113,19 +1115,11 @@ ScatterPlot.prototype = {
update: function() {
var self = this;
try{
var startTime = new Date()
.getTime();
var elapsedTime = 0;
this.compute_size()
.initGrid()
.updateClones()
.updateMenu();
//Donne des informations quant au temps de MàJ des données
elapsedTime = new Date()
.getTime() - startTime;
//console.log("update sp: " + elapsedTime + "ms");
} catch(err) {
sendErrorToDb(err, this.db);
}
......
......@@ -48,6 +48,8 @@ SEGMENT_KEYS = ["4", "4a", "4b"]
function Segment(id, model, database) {
View.call(this, model);
this.type = "Segmenter";
this.useSmartUpdate = true;
this.db = database;
if (typeof config != 'undefined') {
......@@ -501,17 +503,9 @@ Segment.prototype = {
update: function() {
var self = this;
try{
var startTime = new Date()
.getTime();
var elapsedTime = 0;
var list = [];
for (var i = 0; i < this.m.clones.length; i++) list.push(i);
this.updateElem(list);
elapsedTime = new Date()
.getTime() - startTime;
console.log("update seg: " + elapsedTime + "ms");
} catch(err) {
sendErrorToDb(err, this.db);
}
......
function Url(model, win) {
View.call(this, model);
this.type = "Segmenter";
this.useSmartUpdate = true;
this.m = model;
this.window = (typeof win != "undefined") ? win : window
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment