From 10a2c382087e760590080ef5812a98c2f572437d Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Thu, 3 Apr 2025 13:01:26 -0400 Subject: [SharedCache] Log the time it takes to load initial images in the view --- view/sharedcache/core/SharedCacheView.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'view/sharedcache/core/SharedCacheView.cpp') 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("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 elapsed = endTime - startTime; + logger->LogInfo("Automatically loading %zu images took %.3f seconds", loadedImages, elapsed.count()); + } return true; } -- cgit v1.3.1