Hello,
I have a performance question.
There are multiple methods of getting and setting variables. I would like to know what is adviced, or what gives the best performance between them.
Question 1: what method is adviced:
Method 1: single call
var example1 = global.get('storedvariable1',"file");
global.set per variable.
Method 2: multi call
var values=flow.get(["v1","v2"]);
var v1=values[0];
var v2=values[1];
But... method 2 can also be in the form like this:
MQTT.block_active
MQTT.allow_rtc_onoff
MQTT.allow_scheduler
MQTT.allow_solar
MQTT.block_mode
MQTT.message_limit
MQTT.counter
MQTT.messages_yesterday
MQTT.messages_today
MQTT.block_mode_previous
Calling variable MQTT
var MQTT = global.get('MQTT', "file");
In this example, it could be in reality that I only require 2 variables from MQTT in the function after reading.
The questions are:
Q1: what method of getting variables would be best for performance.
Q2: Using method 2 in the form I wrote in the example, would loading the extra variables result in a performance thing?
Store to file vs memoryOnly:
I use 2 storage methods. for live values only use memoryOnly, and for storing graphs or settings store in 'file'.
The settings have a flush timer of 300 seconds.
Q3: when global.getting a variable from "file", does that mean there is a read action done?
Q4: When setting a global variable to 'file' location, does the variable store DIRECTLY to file/disk, or collect it during 300 seconds, and THEN store it to file?
For the amount of writing actions.. I can see there is a significant performance topic here in case the actual writing is done instantly instead of once per 300 seconds.
The things I have read still leave me with this question. I THINK the flush timer is collecting all changed variables and writing it once 300 seconds. But I'd like this confirmed ![]()
Many thanks for all the support here.
Great forum.
Kind regards,