Restore cache capacity after BM_CompileManyTextures benchmark.

The BM_CompileManyTextures benchmark temporarily sets the MuJoCo cache capacity to 0. This change ensures that the original cache capacity is restored after the benchmark completes, preventing side effects on other tests.

PiperOrigin-RevId: 864332653
Change-Id: I5f756e30d4922d5e6f9b70d19ba9d0e31cde9259
This commit is contained in:
Sam Haves
2026-02-02 06:42:12 -08:00
committed by Copybara-Service
parent 683b1b5d38
commit f0d5ed73b2
+6 -1
View File
@@ -114,13 +114,18 @@ void BM_CompileManyTextures(benchmark::State& state) {
// Disable cache to simulate many textures without needing separate
// testdata files.
mj_setCacheCapacity(mj_getCache(), 0);
auto* cache = mj_getCache();
int old_capacity = mj_getCacheCapacity(cache);
mj_setCacheCapacity(cache, 0);
for (auto s : state) {
char error[1024];
mjModel* model = LoadModelFromString(xml, error, sizeof(error));
mj_deleteModel(model);
}
// Reset cache capacity to default value.
mj_setCacheCapacity(cache, old_capacity);
}
BENCHMARK(BM_CompileManyTextures)->Range(10, 100);