Cache weather data
stdedos opened this issue · comments
It is my opinion, that caching the data for a short while (something like 5 minutes / 1 hour / 4 hours), might be more convenient. Then you can:
i) Add "Hold OK" to force refresh, or
ii) Make this behavior optional, by default off for people not wanting that
I know it would help me, because I cycle the cities "at least once", so the waiting period to fetch and re-fetch data "is a bit annoying".
Add-on caching server responses for 30 minutes at Kodi's RAM.
But every time you change the city, add-on calculates the values from saved response. This takes a some time.
I'll see if I can speed up something.
I made performance measurement.
When receiving data from the site, the script is executed in 1.5-2.5 seconds.
When retrieving data from the cache, the script takes 0.07-0.10 seconds.
There is nothing more to optimize here.
😕 Too bad
I see times here measuring to 5-10-15 seconds from boot.
If you add loggable diagnostics in a published version, I'll provide them for you.
I see times here measuring to 5-10-15 seconds from boot.
Just looked at logs. From Kodi start to addon calling passed almost 16 seconds
2021-04-03 19:40:59.125 T:15372 NOTICE: Starting Kodi (18.9 (18.9.0) Git:20201023-0655c2c718). Platform: Windows NT x86 64-bit
2021-04-03 19:41:15.296 T:13480 DEBUG: weather.gismeteo [v.0.5.2]: <Weather ['d:\\KODI\\Portable\\kodi_18\\portable_data\\addons\\weather.gismeteo\\default.py', '3']>
2021-04-03 19:41:18.319 T:13480 DEBUG: weather.gismeteo [v.0.5.2]: Execution time: 3.02 sec
If you add loggable diagnostics in a published version, I'll provide them for you.
You can manually modify default.py from addon folder. You should replace string
weather.run()
by strings
import time
start_time = time.time()
weather.run()
end_time = time.time()
weather.log_debug('Execution time: %.2f sec' % (end_time - start_time))
My problem is that I am running it in a "self-contained Android system", so "quick hacks" like that don't fly as quickly on my side 😕