Lines Matching refs:state
48 void MmapBenchmarkImpl(benchmark::State& state, const struct MmapParams& params, int fd, in MmapBenchmarkImpl() argument
50 for (auto _ : state) { in MmapBenchmarkImpl()
51 if (type == kBenchmarkMunmapOnly) state.PauseTiming(); in MmapBenchmarkImpl()
54 state.SkipWithError(android::base::StringPrintf("mmap failed: %s", strerror(errno)).c_str()); in MmapBenchmarkImpl()
58 if (type == kBenchmarkMmapOnly) state.PauseTiming(); in MmapBenchmarkImpl()
64 if (type == kBenchmarkMunmapOnly) state.ResumeTiming(); in MmapBenchmarkImpl()
67 state.SkipWithError( in MmapBenchmarkImpl()
71 if (type == kBenchmarkMmapOnly) state.ResumeTiming(); in MmapBenchmarkImpl()
75 static void MmapBenchmark(benchmark::State& state, const struct MmapParams& params, int fd, in MmapBenchmark() argument
77 MmapBenchmarkImpl<kBenchmarkAll>(state, params, fd, area); in MmapBenchmark()
80 static void MmapFixedBenchmark(benchmark::State& state, const struct MmapParams& params, int fd, in MmapFixedBenchmark() argument
83 state.SkipWithError("MmapFixedBenchmark called without MAP_FIXED set"); in MmapFixedBenchmark()
91 state.SkipWithError(android::base::StringPrintf("mmap failed: %s", strerror(errno)).c_str()); in MmapFixedBenchmark()
95 MmapBenchmark(state, params, fd, area + offs); in MmapFixedBenchmark()
98 state.SkipWithError(android::base::StringPrintf("munmap failed: %s", strerror(errno)).c_str()); in MmapFixedBenchmark()
103 static void MmapFileBenchmark(benchmark::State& state, const struct MmapParams& params, in MmapFileBenchmark() argument
108 state.SkipWithError( in MmapFileBenchmark()
115 state.SkipWithError( in MmapFileBenchmark()
121 MmapFixedBenchmark(state, params, tf.fd, area_size, offs); in MmapFileBenchmark()
123 MmapBenchmark(state, params, tf.fd); in MmapFileBenchmark()
128 static void BM_syscall_mmap_anon_rw(benchmark::State& state) { in BM_syscall_mmap_anon_rw() argument
132 .size = state.range(0), in BM_syscall_mmap_anon_rw()
135 MmapBenchmark(state, params, 0); in BM_syscall_mmap_anon_rw()
139 static void BM_syscall_mmap_anon_noreserve(benchmark::State& state) { in BM_syscall_mmap_anon_noreserve() argument
143 .size = state.range(0), in BM_syscall_mmap_anon_noreserve()
146 MmapBenchmark(state, params, 0); in BM_syscall_mmap_anon_noreserve()
150 static void BM_syscall_mmap_anon_none(benchmark::State& state) { in BM_syscall_mmap_anon_none() argument
154 .size = state.range(0), in BM_syscall_mmap_anon_none()
157 MmapBenchmark(state, params, 0); in BM_syscall_mmap_anon_none()
162 static void BM_syscall_mmap_anon_rw_fixed(benchmark::State& state) { in BM_syscall_mmap_anon_rw_fixed() argument
166 .size = state.range(0), in BM_syscall_mmap_anon_rw_fixed()
169 MmapFixedBenchmark(state, params, -1, params.size, 0); in BM_syscall_mmap_anon_rw_fixed()
173 static void BM_syscall_mmap_anon_none_fixed(benchmark::State& state) { in BM_syscall_mmap_anon_none_fixed() argument
177 .size = state.range(0), in BM_syscall_mmap_anon_none_fixed()
180 MmapFixedBenchmark(state, params, -1, params.size, 0); in BM_syscall_mmap_anon_none_fixed()
185 static void BM_syscall_mmap_file_rd_priv(benchmark::State& state) { in BM_syscall_mmap_file_rd_priv() argument
189 .size = state.range(0), in BM_syscall_mmap_file_rd_priv()
192 MmapFileBenchmark(state, params, params.size, 0); in BM_syscall_mmap_file_rd_priv()
196 static void BM_syscall_mmap_file_rw_shared(benchmark::State& state) { in BM_syscall_mmap_file_rw_shared() argument
200 .size = state.range(0), in BM_syscall_mmap_file_rw_shared()
203 MmapFileBenchmark(state, params, params.size, 0); in BM_syscall_mmap_file_rw_shared()
208 static void BM_syscall_mmap_file_rw_priv_fixed_start(benchmark::State& state) { in BM_syscall_mmap_file_rw_priv_fixed_start() argument
212 .size = state.range(0), in BM_syscall_mmap_file_rw_priv_fixed_start()
216 MmapFileBenchmark(state, params, params.size * 3, 0); in BM_syscall_mmap_file_rw_priv_fixed_start()
220 static void BM_syscall_mmap_file_rw_priv_fixed_mid(benchmark::State& state) { in BM_syscall_mmap_file_rw_priv_fixed_mid() argument
224 .size = state.range(0), in BM_syscall_mmap_file_rw_priv_fixed_mid()
228 MmapFileBenchmark(state, params, params.size * 3, params.size); in BM_syscall_mmap_file_rw_priv_fixed_mid()
233 static void BM_syscall_mmap_file_rw_priv_fixed_end(benchmark::State& state) { in BM_syscall_mmap_file_rw_priv_fixed_end() argument
237 .size = state.range(0), in BM_syscall_mmap_file_rw_priv_fixed_end()
241 MmapFileBenchmark(state, params, params.size * 3, params.size * 2); in BM_syscall_mmap_file_rw_priv_fixed_end()
246 static void BM_syscall_mmap_anon_mmap_only(benchmark::State& state) { in BM_syscall_mmap_anon_mmap_only() argument
250 .size = state.range(0), in BM_syscall_mmap_anon_mmap_only()
252 MmapBenchmarkImpl<kBenchmarkMmapOnly>(state, params, 0); in BM_syscall_mmap_anon_mmap_only()
256 static void BM_syscall_mmap_anon_munmap_only(benchmark::State& state) { in BM_syscall_mmap_anon_munmap_only() argument
260 .size = state.range(0), in BM_syscall_mmap_anon_munmap_only()
262 MmapBenchmarkImpl<kBenchmarkMunmapOnly>(state, params, 0); in BM_syscall_mmap_anon_munmap_only()
266 void MadviseBenchmark(benchmark::State& state, const struct MmapParams& params, int madvise_flags) { in MadviseBenchmark() argument
269 state.SkipWithError(android::base::StringPrintf("mmap failed: %s", strerror(errno)).c_str()); in MadviseBenchmark()
272 for (auto _ : state) { in MadviseBenchmark()
273 state.PauseTiming(); in MadviseBenchmark()
277 state.ResumeTiming(); in MadviseBenchmark()
283 state.SkipWithError(android::base::StringPrintf("munmap failed: %s", strerror(errno)).c_str()); in MadviseBenchmark()
287 static void BM_syscall_mmap_anon_madvise_dontneed(benchmark::State& state) { in BM_syscall_mmap_anon_madvise_dontneed() argument
291 .size = state.range(0), in BM_syscall_mmap_anon_madvise_dontneed()
293 MadviseBenchmark(state, params, MADV_DONTNEED); in BM_syscall_mmap_anon_madvise_dontneed()
297 static void BM_syscall_mmap_anon_madvise_pageout(benchmark::State& state) { in BM_syscall_mmap_anon_madvise_pageout() argument
301 .size = state.range(0), in BM_syscall_mmap_anon_madvise_pageout()
303 MadviseBenchmark(state, params, MADV_PAGEOUT); in BM_syscall_mmap_anon_madvise_pageout()
307 static void BM_syscall_mmap_anon_madvise_free(benchmark::State& state) { in BM_syscall_mmap_anon_madvise_free() argument
311 .size = state.range(0), in BM_syscall_mmap_anon_madvise_free()
313 MadviseBenchmark(state, params, MADV_FREE); in BM_syscall_mmap_anon_madvise_free()
317 void MprotectBenchmark(benchmark::State& state, const struct MprotectParams& params, void* addr) { in MprotectBenchmark() argument
318 for (auto _ : state) { in MprotectBenchmark()
319 state.PauseTiming(); in MprotectBenchmark()
327 state.ResumeTiming(); in MprotectBenchmark()
330 state.SkipWithError(android::base::StringPrintf("mprotect failed: %m")); in MprotectBenchmark()
334 state.PauseTiming(); in MprotectBenchmark()
337 state.ResumeTiming(); in MprotectBenchmark()
339 state.SkipWithError( in MprotectBenchmark()
346 static void MprotectBenchmarkWithMmapAnon(benchmark::State& state, in MprotectBenchmarkWithMmapAnon() argument
350 state.SkipWithError(android::base::StringPrintf("mmap failed: %m")); in MprotectBenchmarkWithMmapAnon()
354 MprotectBenchmark(state, params, addr); in MprotectBenchmarkWithMmapAnon()
357 state.SkipWithError(android::base::StringPrintf("munmap failed: %m")); in MprotectBenchmarkWithMmapAnon()
360 static void BM_syscall_mmap_anon_mprotect_rw_to_rd(benchmark::State& state) { in BM_syscall_mmap_anon_mprotect_rw_to_rd() argument
364 .size = state.range(0), in BM_syscall_mmap_anon_mprotect_rw_to_rd()
366 MprotectBenchmarkWithMmapAnon(state, params); in BM_syscall_mmap_anon_mprotect_rw_to_rd()
370 static void BM_syscall_mmap_anon_mprotect_rw_to_none(benchmark::State& state) { in BM_syscall_mmap_anon_mprotect_rw_to_none() argument
374 .size = state.range(0), in BM_syscall_mmap_anon_mprotect_rw_to_none()
376 MprotectBenchmarkWithMmapAnon(state, params); in BM_syscall_mmap_anon_mprotect_rw_to_none()
380 static void BM_syscall_mmap_anon_mprotect_rd_to_none(benchmark::State& state) { in BM_syscall_mmap_anon_mprotect_rd_to_none() argument
384 .size = state.range(0), in BM_syscall_mmap_anon_mprotect_rd_to_none()
386 MprotectBenchmarkWithMmapAnon(state, params); in BM_syscall_mmap_anon_mprotect_rd_to_none()
390 static void MprotectBenchmarkWithMmapFile(benchmark::State& state, in MprotectBenchmarkWithMmapFile() argument
395 state.SkipWithError(android::base::StringPrintf("failed to create a temporary file: %m")); in MprotectBenchmarkWithMmapFile()
400 state.SkipWithError(android::base::StringPrintf("ftruncate failed: %m")); in MprotectBenchmarkWithMmapFile()
406 state.SkipWithError(android::base::StringPrintf("mmap failed: %m")); in MprotectBenchmarkWithMmapFile()
410 MprotectBenchmark(state, params, addr); in MprotectBenchmarkWithMmapFile()
413 state.SkipWithError(android::base::StringPrintf("munmap failed: %m")); in MprotectBenchmarkWithMmapFile()
416 static void BM_syscall_mmap_file_mprotect_rw_to_rd(benchmark::State& state) { in BM_syscall_mmap_file_mprotect_rw_to_rd() argument
420 .size = state.range(0), in BM_syscall_mmap_file_mprotect_rw_to_rd()
422 MprotectBenchmarkWithMmapFile(state, params); in BM_syscall_mmap_file_mprotect_rw_to_rd()
426 static void BM_syscall_mmap_file_mprotect_rw_to_none(benchmark::State& state) { in BM_syscall_mmap_file_mprotect_rw_to_none() argument
430 .size = state.range(0), in BM_syscall_mmap_file_mprotect_rw_to_none()
432 MprotectBenchmarkWithMmapFile(state, params); in BM_syscall_mmap_file_mprotect_rw_to_none()
436 static void BM_syscall_mmap_file_mprotect_none_to_rw(benchmark::State& state) { in BM_syscall_mmap_file_mprotect_none_to_rw() argument
440 .size = state.range(0), in BM_syscall_mmap_file_mprotect_none_to_rw()
442 MprotectBenchmarkWithMmapFile(state, params); in BM_syscall_mmap_file_mprotect_none_to_rw()
446 static void BM_syscall_mmap_file_mprotect_none_to_rd(benchmark::State& state) { in BM_syscall_mmap_file_mprotect_none_to_rd() argument
450 .size = state.range(0), in BM_syscall_mmap_file_mprotect_none_to_rd()
452 MprotectBenchmarkWithMmapFile(state, params); in BM_syscall_mmap_file_mprotect_none_to_rd()
456 static void BM_syscall_mmap_file_mprotect_rd_to_none(benchmark::State& state) { in BM_syscall_mmap_file_mprotect_rd_to_none() argument
460 .size = state.range(0), in BM_syscall_mmap_file_mprotect_rd_to_none()
462 MprotectBenchmarkWithMmapFile(state, params); in BM_syscall_mmap_file_mprotect_rd_to_none()