summaryrefslogtreecommitdiffstats
path: root/benchmarks
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-01-16 17:08:31 -0800
committerElliott Hughes <enh@google.com>2015-01-16 17:08:31 -0800
commit1cf32f83d3284785c64d3ea66560d23eec915956 (patch)
tree2cf23fe9c573f6f265db968f3569ac952f754289 /benchmarks
parent481cf21e08a6cbbc686487744f1cb07b6d3f400e (diff)
downloadbionic-1cf32f83d3284785c64d3ea66560d23eec915956.zip
bionic-1cf32f83d3284785c64d3ea66560d23eec915956.tar.gz
bionic-1cf32f83d3284785c64d3ea66560d23eec915956.tar.bz2
Add a benchmark for using stdio to read a file in /proc.
Change-Id: I12517aae19e36b7c022a11e8807aece61bb0cb9c
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/stdio_benchmark.cpp10
1 files changed, 10 insertions, 0 deletions
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);