[libcxx-commits] [libcxx] [libc++] Fix file_status.status.eq.ops.pass.cpp test (PR #73444)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Nov 26 03:25:48 PST 2023
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/73444
The test was missing the `.pass.cpp` suffix to be recognized as a test.
As a result, this was never run and completely broken.
>From 8af99a00f4eb27155eec3d1918476e91f462e1fb Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sun, 26 Nov 2023 12:24:20 +0100
Subject: [PATCH] [libc++] Fix file_status.status.eq.ops.pass.cpp test
The test was missing the `.pass.cpp` suffix to be recognized as a test.
As a result, this was never run and completely broken.
---
.../benchmarks/algorithms/find_if.bench.cpp | 77 +++++++++++++++++++
...cpp => file_status.status.eq.ops.pass.cpp} | 20 ++---
2 files changed, 87 insertions(+), 10 deletions(-)
create mode 100644 libcxx/benchmarks/algorithms/find_if.bench.cpp
rename libcxx/test/std/input.output/filesystems/class.file_status/{file_status.status.eq.ops.cpp => file_status.status.eq.ops.pass.cpp} (52%)
diff --git a/libcxx/benchmarks/algorithms/find_if.bench.cpp b/libcxx/benchmarks/algorithms/find_if.bench.cpp
new file mode 100644
index 000000000000000..b87c575a16b4dcd
--- /dev/null
+++ b/libcxx/benchmarks/algorithms/find_if.bench.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <algorithm>
+#include <benchmark/benchmark.h>
+#include <cstring>
+#include <random>
+#include <vector>
+
+template <class T>
+static void bm_find(benchmark::State& state) {
+ std::vector<T> vec1(state.range(), '1');
+ std::mt19937_64 rng(std::random_device{}());
+
+ for (auto _ : state) {
+ auto idx = rng() % vec1.size();
+ vec1[idx] = '2';
+ benchmark::DoNotOptimize(vec1);
+ benchmark::DoNotOptimize(std::find(vec1.begin(), vec1.end(), T('2')));
+ vec1[idx] = '1';
+ }
+}
+BENCHMARK(bm_find<char>)->DenseRange(1, 8)->Range(16, 1 << 20);
+BENCHMARK(bm_find<short>)->DenseRange(1, 8)->Range(16, 1 << 20);
+BENCHMARK(bm_find<int>)->DenseRange(1, 8)->Range(16, 1 << 20);
+
+template <class T>
+static void bm_ranges_find(benchmark::State& state) {
+ std::vector<T> vec1(state.range(), '1');
+ std::mt19937_64 rng(std::random_device{}());
+
+ for (auto _ : state) {
+ auto idx = rng() % vec1.size();
+ vec1[idx] = '2';
+ benchmark::DoNotOptimize(vec1);
+ benchmark::DoNotOptimize(std::ranges::find(vec1, T('2')));
+ vec1[idx] = '1';
+ }
+}
+BENCHMARK(bm_ranges_find<char>)->DenseRange(1, 8)->Range(16, 1 << 20);
+BENCHMARK(bm_ranges_find<short>)->DenseRange(1, 8)->Range(16, 1 << 20);
+BENCHMARK(bm_ranges_find<int>)->DenseRange(1, 8)->Range(16, 1 << 20);
+
+static void bm_vector_bool_find(benchmark::State& state) {
+ std::vector<bool> vec1(state.range(), false);
+ std::mt19937_64 rng(std::random_device{}());
+
+ for (auto _ : state) {
+ auto idx = rng() % vec1.size();
+ vec1[idx] = true;
+ benchmark::DoNotOptimize(vec1);
+ benchmark::DoNotOptimize(std::find(vec1.begin(), vec1.end(), true));
+ vec1[idx] = false;
+ }
+}
+BENCHMARK(bm_vector_bool_find)->DenseRange(1, 8)->Range(16, 1 << 20);
+
+static void bm_vector_bool_ranges_find(benchmark::State& state) {
+ std::vector<bool> vec1(state.range(), false);
+ std::mt19937_64 rng(std::random_device{}());
+
+ for (auto _ : state) {
+ auto idx = rng() % vec1.size();
+ vec1[idx] = true;
+ benchmark::DoNotOptimize(vec1);
+ benchmark::DoNotOptimize(std::ranges::find(vec1, true));
+ vec1[idx] = false;
+ }
+}
+BENCHMARK(bm_vector_bool_ranges_find)->DenseRange(1, 8)->Range(16, 1 << 20);
+
+BENCHMARK_MAIN();
diff --git a/libcxx/test/std/input.output/filesystems/class.file_status/file_status.status.eq.ops.cpp b/libcxx/test/std/input.output/filesystems/class.file_status/file_status.status.eq.ops.pass.cpp
similarity index 52%
rename from libcxx/test/std/input.output/filesystems/class.file_status/file_status.status.eq.ops.cpp
rename to libcxx/test/std/input.output/filesystems/class.file_status/file_status.status.eq.ops.pass.cpp
index 6b45a39d4a81b4d..8855f1dad41bb2e 100644
--- a/libcxx/test/std/input.output/filesystems/class.file_status/file_status.status.eq.ops.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.file_status/file_status.status.eq.ops.pass.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03 c++11 c++14 c++17
+// UNSUPPORTED: c++03, c++11, c++14, c++17
// <filesystem>
@@ -18,30 +18,30 @@
#include <cassert>
#include <filesystem>
-#include "test_macros.h"
+#include "test_comparisons.h"
void test() {
{
- std::fileystem::file_status f1;
- std::fileystem::file_status f2;
+ std::filesystem::file_status f1;
+ std::filesystem::file_status f2;
assert(testEquality(f1, f2, true));
}
{
- std::fileystem::file_status f1{std::filesystem::file_type::regular, std::filesystem::perms::owner_read};
- std::fileystem::file_status f2{std::filesystem::file_type::regular, std::filesystem::perms::owner_read};
+ std::filesystem::file_status f1{std::filesystem::file_type::regular, std::filesystem::perms::owner_read};
+ std::filesystem::file_status f2{std::filesystem::file_type::regular, std::filesystem::perms::owner_read};
assert(testEquality(f1, f2, true));
}
{
- std::fileystem::file_status f1{std::filesystem::file_type::regular, std::filesystem::perms::owner_read};
- std::fileystem::file_status f2{std::filesystem::file_type::none, std::filesystem::perms::owner_read};
+ std::filesystem::file_status f1{std::filesystem::file_type::regular, std::filesystem::perms::owner_read};
+ std::filesystem::file_status f2{std::filesystem::file_type::none, std::filesystem::perms::owner_read};
assert(testEquality(f1, f2, false));
}
{
- std::fileystem::file_status f1{std::filesystem::file_type::regular, std::filesystem::perms::owner_read};
- std::fileystem::file_status f2{std::filesystem::file_type::regular, std::filesystem::perms::owner_write};
+ std::filesystem::file_status f1{std::filesystem::file_type::regular, std::filesystem::perms::owner_read};
+ std::filesystem::file_status f2{std::filesystem::file_type::regular, std::filesystem::perms::owner_write};
assert(testEquality(f1, f2, false));
}
More information about the libcxx-commits
mailing list