From 1cf32f83d3284785c64d3ea66560d23eec915956 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 16 Jan 2015 17:08:31 -0800 Subject: Add a benchmark for using stdio to read a file in /proc. Change-Id: I12517aae19e36b7c022a11e8807aece61bb0cb9c --- benchmarks/stdio_benchmark.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'benchmarks') diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp index 386ea04..fe25d76 100644 --- a/benchmarks/stdio_benchmark.cpp +++ b/benchmarks/stdio_benchmark.cpp @@ -65,3 +65,13 @@ static void BM_stdio_fwrite_unbuffered(int iters, int chunk_size) { ReadWriteTest(iters, chunk_size, fwrite, false); } BENCHMARK(BM_stdio_fwrite_unbuffered)->AT_COMMON_SIZES; + +static void BM_stdio_fopen_fgets_fclose(int iters) { + char buf[1024]; + for (int i = 0; i < iters; ++i) { + FILE* fp = fopen("/proc/version", "re"); + fgets(buf, sizeof(buf), fp); + fclose(fp); + } +} +BENCHMARK(BM_stdio_fopen_fgets_fclose); -- cgit v1.1