Performance Improvement on Charts

This commit is contained in:
Luis Fernando Molina committed 2020-03-14 15:51:43 +01:00
1 parent 61f41f396a
commit 868bad300c
14 files changed
+36 -38

No files matched your search

+4 -9
View File
@@ -61,11 +61,11 @@ function newAnimation () {
try {
if (window.canvasApp.visible === true) {
/* We set the canvas to its normal width and height */
browserCanvas.width = window.innerWidth
browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN
// browserCanvas.width = window.innerWidth
// browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN
/* First thing is to clear the actual canvas */
// clearBrowserCanvas()
clearBrowserCanvas()
/* We loop through the callback functions collections and execute them all. */
let performanceMap = new Map()
@@ -162,12 +162,7 @@ function newAnimation () {
}
function clearBrowserCanvas () {
browserCanvasContext.beginPath()
browserCanvasContext.rect(0, 0, browserCanvas.width, browserCanvas.height)
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
browserCanvasContext.closePath()
browserCanvasContext.fill()
browserCanvasContext.clearRect(0, 0, browserCanvas.width, browserCanvas.height)
}
}
+6 -11
View File
@@ -24,7 +24,6 @@ function newPlotter () {
thisObject.container = container
let coordinateSystem
let plotterModuleConfig
let slotHeight = (canvas.chartingSpace.viewport.visibleArea.bottomRight.y - canvas.chartingSpace.viewport.visibleArea.topLeft.y) / 10 // This is the amount of slots available
let mustRecalculateDataPoints = false
let atMousePositionFillStyles = new Map()
@@ -82,7 +81,6 @@ function newPlotter () {
finalizeCoordinateSystem()
coordinateSystem = undefined
plotterModuleConfig = undefined
slotHeight = undefined
mustRecalculateDataPoints = undefined
atMousePositionFillStyles = undefined
@@ -498,6 +496,10 @@ function newPlotter () {
for (let i = 0; i < records.length; i++) {
let record = records[i]
/*
In the formulas to create plotters, we allos users to reference the previous record.
To enable that we need to link all records to the previous one in this way.
*/
if (i == 0) {
record.previous = record
} else {
@@ -555,7 +557,7 @@ function newPlotter () {
if (logged === false) {
logged = true
}
/* Only calculate the datapoints for this record, if we have not calculate it before. */
/* It seems we need to calculate the data points this time. */
for (let k = 0; k < productDefinition.referenceParent.shapes.chartPoints.length; k++) {
let chartPoints = productDefinition.referenceParent.shapes.chartPoints[k]
for (let j = 0; j < chartPoints.points.length; j++) {
@@ -582,13 +584,6 @@ function newPlotter () {
/* Store the data point at the local map */
dataPoints.set(point.id, dataPoint)
if (plotterModuleConfig !== undefined) {
if (plotterModuleConfig.slot !== undefined) {
/* We reset the y coordinate since it will be transformed with another coordinate system to fit into a slot. */
dataPoint.y = (-1) * y * coordinateSystem.scale.y + (plotterModuleConfig.slot.number - 1) * slotHeight + canvas.chartingSpace.viewport.visibleArea.topLeft.y
}
}
}
}
}
@@ -769,7 +764,7 @@ function newPlotter () {
}
}
if (coordinateSystem.autoMinYScale === true || coordinateSystem.autosMaxScale === true) {
if (coordinateSystem.autoMinYScale === true || coordinateSystem.autoMinYScale === true) {
mustRecalculateDataPoints = true
} else {
mustRecalculateDataPoints = false
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const INTENSIVE_LOG = false;
@@ -21,6 +21,7 @@
};
let utilities = UTILITIES.newCloudUtilities(bot, logger);
let fileStorage = FILE_STORAGE.newFileStorage(logger);
let statusDependencies;
let beginingOfMarket
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -17,6 +17,7 @@
};
let statusDependencies;
let fileStorage = FILE_STORAGE.newFileStorage(logger);
return thisObject;
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -23,6 +23,7 @@
};
let utilities = UTILITIES.newCloudUtilities(bot, logger);
let fileStorage = FILE_STORAGE.newFileStorage(logger);
let statusDependencies;
let beginingOfMarket
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -23,6 +23,7 @@
};
let utilities = UTILITIES.newCloudUtilities(bot, logger);
let fileStorage = FILE_STORAGE.newFileStorage(logger);
let statusDependencies;
let beginingOfMarket
@@ -1,5 +1,5 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage, STATUS_REPORT, EXCHANGE_API) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -15,6 +15,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt
};
let utilities = UTILITIES.newCloudUtilities(bot, logger)
let fileStorage = FILE_STORAGE.newFileStorage(logger);
let statusDependencies
const ONE_MIN = 60000
@@ -1,5 +1,5 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage, STATUS_REPORT, EXCHANGE_API) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE, STATUS_REPORT, EXCHANGE_API) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -14,6 +14,7 @@ exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileSt
};
let utilities = UTILITIES.newCloudUtilities(bot, logger)
let fileStorage = FILE_STORAGE.newFileStorage(logger);
let statusDependencies
const ONE_MINUTE = 60000
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const INTENSIVE_LOG = false;
@@ -24,6 +24,7 @@
};
let utilities = UTILITIES.newCloudUtilities(bot, logger);
let fileStorage = FILE_STORAGE.newFileStorage(logger);
let statusDependencies;
let beginingOfMarket
@@ -1,4 +1,4 @@
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) {
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, FILE_STORAGE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
@@ -23,6 +23,7 @@
};
let statusDependencies;
let fileStorage = FILE_STORAGE.newFileStorage(logger);
return thisObject;
+7 -6
View File
@@ -8,6 +8,7 @@ exports.newFileStorage = function newFileStorage(logger) {
const RETRY_TIME_IN_MILISECONDS = 250
let currentRetryGetTextFile = 0
let currentRetryWriteTextFile = 0
let currentRetryDeleteTextFile = 0
if (logger === undefined) { // Dummy logger
logger = {}
@@ -242,14 +243,14 @@ exports.newFileStorage = function newFileStorage(logger) {
}
function retry() {
if (currentRetryWriteTextFile < MAX_RETRY) {
currentRetryWriteTextFile++
logger.write(MODULE_NAME, '[WARN] FileStorage -> createTextFile -> retry -> Will try to write the file again -> Retry #: ' + currentRetryWriteTextFile)
if (currentRetryDeleteTextFile < MAX_RETRY) {
currentRetryDeleteTextFile++
logger.write(MODULE_NAME, '[WARN] FileStorage -> deleteTextFile -> retry -> Will try to delete the file again -> Retry #: ' + currentRetryDeleteTextFile)
createTextFile(filePath, fileContent, callBackFunction)
} else {
currentRetryWriteTextFile = 0
logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> Max retries reached writting a file. Giving up.')
logger.write(MODULE_NAME, '[ERROR] FileStorage -> createTextFile -> retry -> file = ' + fileLocation)
currentRetryDeleteTextFile = 0
logger.write(MODULE_NAME, '[ERROR] FileStorage -> deleteTextFile -> retry -> Max retries reached deleting a file. Giving up.')
logger.write(MODULE_NAME, '[ERROR] FileStorage -> deleteTextFile -> retry -> file = ' + fileLocation)
callBackFunction(global.DEFAULT_FAIL_RESPONSE)
}
}
+1 -1
View File
@@ -493,7 +493,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> Entering function."); }
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, fileStorage);
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE);
usertBot.initialize(statusDependencies, onInizialized);
+1 -1
View File
@@ -391,7 +391,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeUserBot -> Entering function."); }
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, fileStorage, STATUS_REPORT, exchangeAPI);
usertBot = USER_BOT_MODULE.newUserBot(bot, logger, COMMONS_MODULE, UTILITIES, FILE_STORAGE, STATUS_REPORT, exchangeAPI);
usertBot.initialize(statusDependencies, onInizialized);
+1 -2
View File
@@ -163,8 +163,7 @@ function bootLoader() {
let event = {
seconds: (new Date()).getSeconds()
}
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event)
global.SYSTEM_EVENT_HANDLER.raiseEvent(key, 'Heartbeat', event)
}
for (let processIndex = 0; processIndex < global.TASK_NODE.bot.processes.length; processIndex++) {