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:
committed by
Copybara-Service
parent
683b1b5d38
commit
f0d5ed73b2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user