mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
35 lines
771 B
C++
35 lines
771 B
C++
|
/*
|
||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
|
*
|
||
|
* This software may be used and distributed according to the terms of the
|
||
|
* GNU General Public License version 2.
|
||
|
*/
|
||
|
|
||
|
#include <folly/Exception.h>
|
||
|
#include <folly/File.h>
|
||
|
#include <gflags/gflags.h>
|
||
|
#include "eden/fs/benchharness/Bench.h"
|
||
|
|
||
|
namespace {
|
||
|
|
||
|
DEFINE_string(
|
||
|
filename,
|
||
|
"stat.tmp",
|
||
|
"Path which should be opened and repeatedly stat'd");
|
||
|
|
||
|
void call_fstat(benchmark::State& state) {
|
||
|
folly::File file{FLAGS_filename, O_CREAT | O_RDONLY | O_CLOEXEC};
|
||
|
struct stat buf;
|
||
|
|
||
|
for (auto _ : state) {
|
||
|
folly::checkUnixError(::fstat(file.fd(), &buf), "fstat failed");
|
||
|
}
|
||
|
|
||
|
folly::checkUnixError(::unlink(FLAGS_filename.c_str()));
|
||
|
}
|
||
|
BENCHMARK(call_fstat);
|
||
|
|
||
|
} // namespace
|
||
|
|
||
|
EDEN_BENCHMARK_MAIN();
|