summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/SharedCacheView.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-03 13:01:26 -0400
committerMason Reed <mason@vector35.com>2025-04-03 13:01:26 -0400
commit10a2c382087e760590080ef5812a98c2f572437d (patch)
tree3775822395591acc3cf4af9907a37b9cce3be5e7 /view/sharedcache/core/SharedCacheView.cpp
parent578c5e77a60957a4d04eaac000679de3e5534e7b (diff)
[SharedCache] Log the time it takes to load initial images in the view
Diffstat (limited to 'view/sharedcache/core/SharedCacheView.cpp')
-rw-r--r--view/sharedcache/core/SharedCacheView.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/view/sharedcache/core/SharedCacheView.cpp b/view/sharedcache/core/SharedCacheView.cpp
index 43dc63ff..d07d8614 100644
--- a/view/sharedcache/core/SharedCacheView.cpp
+++ b/view/sharedcache/core/SharedCacheView.cpp
@@ -848,10 +848,19 @@ bool SharedCacheView::Init()
autoLoadPattern = settings->Get<std::string>("loader.dsc.autoLoadPattern", this);
logger->LogDebug("Loading images using pattern: %s", autoLoadPattern.c_str());
- std::regex autoLoadRegex(autoLoadPattern);
- for (const auto& [_, image] : cacheController->GetCache().GetImages())
- if (std::regex_match(image.GetName(), autoLoadRegex))
- cacheController->ApplyImage(*this, image);
+ {
+ // Load all images that match the `autoLoadPattern`.
+ auto startTime = std::chrono::high_resolution_clock::now();
+ size_t loadedImages = 0;
+ std::regex autoLoadRegex(autoLoadPattern);
+ for (const auto& [_, image] : cacheController->GetCache().GetImages())
+ if (std::regex_match(image.GetName(), autoLoadRegex))
+ if (cacheController->ApplyImage(*this, image))
+ ++loadedImages;
+ auto endTime = std::chrono::high_resolution_clock::now();
+ std::chrono::duration<double> elapsed = endTime - startTime;
+ logger->LogInfo("Automatically loading %zu images took %.3f seconds", loadedImages, elapsed.count());
+ }
return true;
}