From de173fff12b2b9c20acd1a1dd1154eebf91e676c Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Sun, 3 Sep 2017 17:54:29 +0200 Subject: New: Purge loaded FIT files during check operation. This will significantly reduce the memory consumption and increases the check speed with several hundreds of FIT files. --- lib/postrunner/FFS_Activity.rb | 4 +++- lib/postrunner/FitFileStore.rb | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/postrunner/FFS_Activity.rb b/lib/postrunner/FFS_Activity.rb index 46ea2bf..138912f 100644 --- a/lib/postrunner/FFS_Activity.rb +++ b/lib/postrunner/FFS_Activity.rb @@ -288,7 +288,9 @@ module PostRunner end end - private + def purge_fit_file + @fit_activity = nil + end end diff --git a/lib/postrunner/FitFileStore.rb b/lib/postrunner/FitFileStore.rb index ab6fefc..d5dba15 100644 --- a/lib/postrunner/FitFileStore.rb +++ b/lib/postrunner/FitFileStore.rb @@ -209,7 +209,17 @@ module PostRunner @store['devices'].each do |id, device| list += device.activities end - list.sort + # Sort the activites by timestamps (oldest to newest). As the list is + # composed from multiple devices, there is a small chance of identical + # timestamps. To guarantee a stable list, we use the long UID of the + # device in cases of identical timestamps. + list.sort! do |a1, a2| + a1.timestamp == a2.timestamp ? + a1.device.long_uid <=> a2.device.long_uid : + a1.timestamp <=> a2.timestamp + end + + list end # Read in all Monitoring_B FIT files that overlap with the given interval. @@ -305,11 +315,10 @@ module PostRunner def check records = @store['records'] records.delete_all_records - activities.sort do |a1, a2| - a1.timestamp <=> a2.timestamp - end.each do |a| + activities.each do |a| a.check records.scan_activity_for_records(a) + a.purge_fit_file end records.generate_html_reports generate_html_index_pages -- cgit v1.2.3