Skip to content

Commit

Permalink
Add runtime access to cache database. Let load tests reset cache for …
Browse files Browse the repository at this point in the history
…cold / warm testing
  • Loading branch information
csciguy8 committed Sep 11, 2023
1 parent 61feff1 commit a6a353b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
20 changes: 14 additions & 6 deletions Source/CesiumRuntime/Private/CesiumRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,28 @@ std::string getCacheDatabaseName() {

} // namespace

std::shared_ptr<CesiumAsync::ICacheDatabase>& getCacheDatabase() {
static int MaxCacheItems =
GetDefault<UCesiumRuntimeSettings>()->MaxCacheItems;

static std::shared_ptr<CesiumAsync::ICacheDatabase> pCacheDatabase =
std::make_shared<CesiumAsync::SqliteCache>(
spdlog::default_logger(),
getCacheDatabaseName(),
MaxCacheItems);

return pCacheDatabase;
}

const std::shared_ptr<CesiumAsync::IAssetAccessor>& getAssetAccessor() {
static int RequestsPerCachePrune =
GetDefault<UCesiumRuntimeSettings>()->RequestsPerCachePrune;
static int MaxCacheItems =
GetDefault<UCesiumRuntimeSettings>()->MaxCacheItems;
static std::shared_ptr<CesiumAsync::IAssetAccessor> pAssetAccessor =
std::make_shared<CesiumAsync::GunzipAssetAccessor>(
std::make_shared<CesiumAsync::CachingAssetAccessor>(
spdlog::default_logger(),
std::make_shared<UnrealAssetAccessor>(),
std::make_shared<CesiumAsync::SqliteCache>(
spdlog::default_logger(),
getCacheDatabaseName(),
MaxCacheItems),
getCacheDatabase(),
RequestsPerCachePrune));
return pAssetAccessor;
}
13 changes: 8 additions & 5 deletions Source/CesiumRuntime/Private/Tests/CesiumLoadTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Tests/AutomationCommon.h"
#include "Tests/AutomationEditorCommon.h"

#include "CesiumAsync/ICacheDatabase.h"
#include "CesiumGltfComponent.h"
#include "CesiumRuntime.h"
#include "CesiumSceneGeneration.h"
Expand Down Expand Up @@ -178,8 +179,10 @@ bool RunLoadTest(
return true;
}

void clearDiskCache(SceneGenerationContext& context) {
// TODO
void clearCacheDb(SceneGenerationContext& context) {
std::shared_ptr<CesiumAsync::ICacheDatabase> pCacheDatabase =
getCacheDatabase();
pCacheDatabase->clearAll();
}

void refreshTilesets(SceneGenerationContext& context) {
Expand All @@ -189,7 +192,7 @@ void refreshTilesets(SceneGenerationContext& context) {
bool FCesiumLoadTestDenver::RunTest(const FString& Parameters) {

std::vector<TestPass> testPasses;
testPasses.push_back(TestPass{"Cold Cache", clearDiskCache, nullptr});
testPasses.push_back(TestPass{"Cold Cache", clearCacheDb, nullptr});
testPasses.push_back(TestPass{"Warm Cache", refreshTilesets, nullptr});

return RunLoadTest(GetTestName(), setupForDenver, testPasses);
Expand All @@ -198,7 +201,7 @@ bool FCesiumLoadTestDenver::RunTest(const FString& Parameters) {
bool FCesiumLoadTestGoogleplex::RunTest(const FString& Parameters) {

std::vector<TestPass> testPasses;
testPasses.push_back(TestPass{"Cold Cache", clearDiskCache, nullptr});
testPasses.push_back(TestPass{"Cold Cache", clearCacheDb, nullptr});
testPasses.push_back(TestPass{"Warm Cache", refreshTilesets, nullptr});

return RunLoadTest(GetTestName(), setupForGoogleTiles, testPasses);
Expand Down Expand Up @@ -245,7 +248,7 @@ bool FCesiumLoadTestMontrealPointCloud::RunTest(const FString& Parameters) {
};

std::vector<TestPass> testPasses;
testPasses.push_back(TestPass{"Cold Cache", clearDiskCache, nullptr});
testPasses.push_back(TestPass{"Cold Cache", clearCacheDb, nullptr});
testPasses.push_back(TestPass{"Adjust", adjustCamera, verifyVisibleTiles});

return RunLoadTest(GetTestName(), setupForMontrealPointCloud, testPasses);
Expand Down
4 changes: 4 additions & 0 deletions Source/CesiumRuntime/Public/CesiumRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class UCesiumRasterOverlay;
namespace CesiumAsync {
class AsyncSystem;
class IAssetAccessor;
class ICacheDatabase;
} // namespace CesiumAsync

DECLARE_LOG_CATEGORY_EXTERN(LogCesium, Log, All);
Expand Down Expand Up @@ -48,3 +49,6 @@ CESIUMRUNTIME_API extern FCesiumRasterOverlayIonTroubleshooting
CESIUMRUNTIME_API CesiumAsync::AsyncSystem& getAsyncSystem() noexcept;
CESIUMRUNTIME_API const std::shared_ptr<CesiumAsync::IAssetAccessor>&
getAssetAccessor();

CESIUMRUNTIME_API std::shared_ptr<CesiumAsync::ICacheDatabase>&
getCacheDatabase();

0 comments on commit a6a353b

Please sign in to comment.