aboutsummaryrefslogtreecommitdiffhomepage
path: root/benchmark
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2023-01-04 17:25:30 +0300
committerlevlam <levlam@telegram.org>2023-01-04 17:25:30 +0300
commit3573990d524123b861730827366f898183c998f1 (patch)
treebd710a4920fa0d05408ad4dc650f2df5d127d2c4 /benchmark
parent8df67f0c3a77fd9bb07ef05c68042cd5870986a0 (diff)
Support symbolic links in walk_path.
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/bench_misc.cpp24
-rw-r--r--benchmark/rmdir.cpp17
2 files changed, 19 insertions, 22 deletions
diff --git a/benchmark/bench_misc.cpp b/benchmark/bench_misc.cpp
index 18b68417f..1cbbbe170 100644
--- a/benchmark/bench_misc.cpp
+++ b/benchmark/bench_misc.cpp
@@ -228,13 +228,7 @@ class CreateFileBench final : public td::Benchmark {
}
}
void tear_down() final {
- td::walk_path("A/", [&](td::CSlice path, auto type) {
- if (type == td::WalkPath::Type::ExitDir) {
- td::rmdir(path).ignore();
- } else if (type == td::WalkPath::Type::NotDir) {
- td::unlink(path).ignore();
- }
- }).ignore();
+ td::rmrf("A/").ignore();
}
};
@@ -250,22 +244,10 @@ class WalkPathBench final : public td::Benchmark {
}
void run(int n) final {
int cnt = 0;
- td::walk_path("A/", [&](td::CSlice path, auto type) {
- if (type == td::WalkPath::Type::EnterDir) {
- return;
- }
- td::stat(path).ok();
- cnt++;
- }).ignore();
+ td::rmrf("A/").ignore();
}
void tear_down() final {
- td::walk_path("A/", [&](td::CSlice path, auto type) {
- if (type == td::WalkPath::Type::ExitDir) {
- td::rmdir(path).ignore();
- } else if (type == td::WalkPath::Type::NotDir) {
- td::unlink(path).ignore();
- }
- }).ignore();
+ td::rmrf("A/").ignore();
}
};
diff --git a/benchmark/rmdir.cpp b/benchmark/rmdir.cpp
index 163f2986b..1a1a7133b 100644
--- a/benchmark/rmdir.cpp
+++ b/benchmark/rmdir.cpp
@@ -17,8 +17,23 @@ int main(int argc, char *argv[]) {
auto status = td::walk_path(dir, [&](td::CSlice path, auto type) {
if (type != td::WalkPath::Type::EnterDir) {
cnt++;
- LOG(INFO) << path << " " << (type == td::WalkPath::Type::ExitDir);
}
+ auto type_name = [&] {
+ switch (type) {
+ case td::WalkPath::Type::EnterDir:
+ return td::CSlice("Open");
+ case td::WalkPath::Type::ExitDir:
+ return td::CSlice("Exit");
+ case td::WalkPath::Type::RegularFile:
+ return td::CSlice("File");
+ case td::WalkPath::Type::Symlink:
+ return td::CSlice("Link");
+ default:
+ UNREACHABLE();
+ return td::CSlice();
+ }
+ }();
+ LOG(INFO) << type_name << ' ' << path;
//if (is_dir) {
// td::rmdir(path);
//} else {