Skip to content

Commit

Permalink
Updated Simd
Browse files Browse the repository at this point in the history
  • Loading branch information
WillisMedwell committed Feb 5, 2024
1 parent ada17ef commit fcc4ec6
Show file tree
Hide file tree
Showing 6 changed files with 382 additions and 169 deletions.
32 changes: 28 additions & 4 deletions benchmark/BenchSimd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ auto all_a(size_t max) -> std::string {
v.resize(max);
std::fill(v.begin(), v.end(), 'a');
v.append("a");
v.append("stri");
v.append("stringer");
return v;
}
const static std::string LONG_STRING = all_a(10000);
Expand Down Expand Up @@ -50,7 +50,6 @@ static void BM_Std_find_char(benchmark::State& state) {
BENCHMARK(BM_Std_find_char);



static void BM_Uty_find_first_of_char(benchmark::State& state) {
const auto data = std::to_array({ 'z', 'o', 'n' });
for (auto _ : state) {
Expand All @@ -63,8 +62,6 @@ BENCHMARK(BM_Uty_find_first_of_char);
static void BM_Std_find_first_of_chars(benchmark::State& state) {
const auto data = std::to_array({ 'z', 'o', 'n' });
for (auto _ : state) {
constexpr static std::string_view charsToSearch = "zon";

volatile auto iter = std::find_first_of(LONG_STRING.begin(), LONG_STRING.end(), data.begin(), data.end());
benchmark::DoNotOptimize(iter);
}
Expand Down Expand Up @@ -114,4 +111,31 @@ static void BM_Std_search_char_4letters(benchmark::State& state) {
}
BENCHMARK(BM_Std_search_char_4letters);


static void BM_Uty_search_char_8letters(benchmark::State& state) {
std::string_view find = "stringer";
for (auto _ : state) {
volatile auto iter = Utily::Simd128::Char::search(
LONG_STRING.data(),
LONG_STRING.size(),
find.data(),
find.size());
benchmark::DoNotOptimize(iter);
}
}
BENCHMARK(BM_Uty_search_char_8letters);

static void BM_Std_search_char_8letters(benchmark::State& state) {
std::string_view find = "stringer";
for (auto _ : state) {
volatile auto iter = std::search(
LONG_STRING.begin(),
LONG_STRING.end(),
find.begin(),
find.end());
benchmark::DoNotOptimize(iter);
}
}
BENCHMARK(BM_Std_search_char_8letters);

#endif
6 changes: 3 additions & 3 deletions build-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ if not exist "build-native\" (
mkdir build-native
)
cd build-native
call cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_UTILY_TESTS=1 -DBUILD_UTILY_BENCHMARKS=1
call cmake --build . --config Release
call cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DBUILD_UTILY_TESTS=1 -DBUILD_UTILY_BENCHMARKS=1
call cmake --build . --config Debug
cd ..

@REM WEB
Expand All @@ -22,4 +22,4 @@ cd ..

cd build-native
call UtilyTest.exe
call UtilyBenchmark.exe
@REM call UtilyBenchmark.exe
Loading

0 comments on commit fcc4ec6

Please sign in to comment.