From e623beb1ae18dbaa371072ae02d651c82e01f022 Mon Sep 17 00:00:00 2001 From: Tom Vercauteren Date: Sat, 17 Feb 2024 18:05:09 +0100 Subject: [PATCH 1/7] cleanup cmake code to run on more platforms --- .gitmodules | 3 -- CMakeLists.txt | 140 +++++++++++++++++++++++------------------------- libs/googletest | 1 - 3 files changed, 68 insertions(+), 76 deletions(-) delete mode 160000 libs/googletest diff --git a/.gitmodules b/.gitmodules index 234263c..4a19305 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "libs/googletest"] - path = libs/googletest - url = https://github.com/google/googletest.git [submodule "libs/cppcodec"] path = libs/cppcodec url = https://github.com/tplgy/cppcodec.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f72db2..eaacdf5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,82 +1,78 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.0) -#CLANG compiler activation options -SET (CMAKE_C_COMPILER "/usr/bin/clang-12") -SET (CMAKE_CXX_COMPILER "/usr/bin/clang++-12") +cmake_minimum_required(VERSION 3.25) +project(base64-banchmark) -SET(CMAKE_BUILD_TYPE Release) -SET(NAME base64.bin) -PROJECT(${NAME}) -ENABLE_TESTING() +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) -# Update if necessary -IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - IF("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O2") - else() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") - endif() -endif() +set(CMAKE_BUILD_TYPE Release) +enable_testing() -# BUILD AND INCLUDE GOOGLETEST -ADD_SUBDIRECTORY(libs/googletest/) -INCLUDE_DIRECTORIES(libs/googletest/googletest/include) +# Get googletest +include(FetchContent) +FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG 750d67d809700ae8fca6d610f7b41b71aa161808 + SYSTEM +) +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) -INCLUDE_DIRECTORIES(libs) +set_target_properties(gtest PROPERTIES CXX_CLANG_TIDY "") +set_target_properties(gtest_main PROPERTIES CXX_CLANG_TIDY "") +set_target_properties(gmock PROPERTIES CXX_CLANG_TIDY "") +set_target_properties(gmock_main PROPERTIES CXX_CLANG_TIDY "") -AUX_SOURCE_DIRECTORY(./src/ CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/adp-gmbh.ch CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/apache CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/arduino CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/DaedalusAlpha CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/ElegantDice CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/gnome CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/InternetSoftwareConsortium CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/JouniMalinen CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/libb64 CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/libcurl CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/LihO CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/ManuelMartinez CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/NibbleAndAHalf CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/omnifarious CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/polfosol CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/user152949 CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/wikibooks.org CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/adition CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/A.Hristov CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/tomykaria CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/stov-180947 CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/libb64/libb64/src C_SOURCES) -AUX_SOURCE_DIRECTORY(./src/picobase64 C_SOURCES) -AUX_SOURCE_DIRECTORY(./libs/chromium/modp_b64 CTR_SOURCES) -AUX_SOURCE_DIRECTORY(./src/modp_b64_chromium CTR_SOURCES) +include_directories(libs) -INCLUDE_DIRECTORIES(libs/cppcodec) -AUX_SOURCE_DIRECTORY(./src/cppcodec CTR_SOURCES) +aux_source_directory(./src/ CTR_SOURCES) +aux_source_directory(./src/adp-gmbh.ch CTR_SOURCES) +aux_source_directory(./src/apache CTR_SOURCES) +aux_source_directory(./src/arduino CTR_SOURCES) +aux_source_directory(./src/DaedalusAlpha CTR_SOURCES) +aux_source_directory(./src/ElegantDice CTR_SOURCES) +aux_source_directory(./src/gnome CTR_SOURCES) +aux_source_directory(./src/InternetSoftwareConsortium CTR_SOURCES) +aux_source_directory(./src/JouniMalinen CTR_SOURCES) +aux_source_directory(./src/libb64 CTR_SOURCES) +aux_source_directory(./src/libcurl CTR_SOURCES) +aux_source_directory(./src/LihO CTR_SOURCES) +aux_source_directory(./src/ManuelMartinez CTR_SOURCES) +aux_source_directory(./src/NibbleAndAHalf CTR_SOURCES) +aux_source_directory(./src/omnifarious CTR_SOURCES) +aux_source_directory(./src/polfosol CTR_SOURCES) +aux_source_directory(./src/user152949 CTR_SOURCES) +aux_source_directory(./src/wikibooks.org CTR_SOURCES) +aux_source_directory(./src/adition CTR_SOURCES) +aux_source_directory(./src/A.Hristov CTR_SOURCES) +aux_source_directory(./src/tomykaria CTR_SOURCES) +aux_source_directory(./src/stov-180947 CTR_SOURCES) +aux_source_directory(./src/libb64/libb64/src C_SOURCES) +aux_source_directory(./src/picobase64 C_SOURCES) -INCLUDE_DIRECTORIES(libs/boost/utility/include) -INCLUDE_DIRECTORIES(libs/boost/serialization/include) -INCLUDE_DIRECTORIES(libs/boost/config/include) -INCLUDE_DIRECTORIES(libs/boost/detail/include) -INCLUDE_DIRECTORIES(libs/boost/preprocessor/include) -INCLUDE_DIRECTORIES(libs/boost/core/include) -INCLUDE_DIRECTORIES(libs/boost/type_traits/include) -INCLUDE_DIRECTORIES(libs/boost/iterator/include) -INCLUDE_DIRECTORIES(libs/boost/mpl/include) -INCLUDE_DIRECTORIES(libs/boost/static_assert/include) -INCLUDE_DIRECTORIES(libs/boost/assert/include) -AUX_SOURCE_DIRECTORY(./src/boost CTR_SOURCES) +aux_source_directory(./libs/chromium/modp_b64 CTR_SOURCES) +aux_source_directory(./src/modp_b64_chromium CTR_SOURCES) -SET_SOURCE_FILES_PROPERTIES( ${CTR_SOURCES} PROPERTIES LANGUAGE CXX ) -SET_SOURCE_FILES_PROPERTIES( ${C_SOURCES} PROPERTIES LANGUAGE C ) +include_directories(libs/cppcodec) +aux_source_directory(./src/cppcodec CTR_SOURCES) -ADD_EXECUTABLE(${NAME} ${CTR_SOURCES} ${C_SOURCES}) -IF(UNIX AND (NOT APPLE)) - TARGET_LINK_LIBRARIES(${NAME} gtest pthread stdc++fs) -else() - TARGET_LINK_LIBRARIES(${NAME} gtest pthread) -endif() +include_directories(libs/boost/utility/include) +include_directories(libs/boost/serialization/include) +include_directories(libs/boost/config/include) +include_directories(libs/boost/detail/include) +include_directories(libs/boost/preprocessor/include) +include_directories(libs/boost/core/include) +include_directories(libs/boost/type_traits/include) +include_directories(libs/boost/iterator/include) +include_directories(libs/boost/mpl/include) +include_directories(libs/boost/static_assert/include) +include_directories(libs/boost/assert/include) +aux_source_directory(./src/boost CTR_SOURCES) + +set_source_files_properties( ${CTR_SOURCES} PROPERTIES LANGUAGE CXX ) +set_source_files_properties( ${C_SOURCES} PROPERTIES LANGUAGE C ) + +add_executable(${PROJECT_NAME} ${CTR_SOURCES} ${C_SOURCES}) +target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gtest GTest::gtest_main) diff --git a/libs/googletest b/libs/googletest deleted file mode 160000 index c9461a9..0000000 --- a/libs/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c9461a9b55ba954df0489bab6420eb297bed846b From e20571f2c806e4a38c2c98d831baef8985426c23 Mon Sep 17 00:00:00 2001 From: Tom Vercauteren Date: Sun, 18 Feb 2024 14:39:56 +0100 Subject: [PATCH 2/7] Added 2 libs and added basic github CI - https://github.com/matheusgomes28/base64pp and https://github.com/tobiaslocker/base64 --- .github/workflows/cmake.yml | 40 ++++++++++++++++++++++++++++++++ .gitignore | 3 +++ .gitmodules | 6 +++++ CMakeLists.txt | 22 ++++++++++++++---- libs/base64-tl | 1 + libs/base64pp | 1 + src/base64-tl/test_base64-tl.cpp | 20 ++++++++++++++++ src/base64pp/test_base64pp.cpp | 22 ++++++++++++++++++ src/main.cpp | 13 ++++++----- 9 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/cmake.yml create mode 160000 libs/base64-tl create mode 160000 libs/base64pp create mode 100644 src/base64-tl/test_base64-tl.cpp create mode 100644 src/base64pp/test_base64pp.cpp diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..349150f --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,40 @@ +name: CMake + +on: [push, pull_request] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: RelWithDebInfo + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + + - name: Install optional tools (clang-tidy) + if: matrix.os == 'ubuntu-latest' + run: sudo apt-get install -y clang-tidy + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. + # `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} . + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure + diff --git a/.gitignore b/.gitignore index de8b940..789c278 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ base64.bin Makefile CTestTestfile.cmake *.vcxproj.user + +# Other +.#* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 4a19305..1074144 100644 --- a/.gitmodules +++ b/.gitmodules @@ -52,3 +52,9 @@ [submodule "libs/IMUtility"] path = libs/IMUtility url = https://github.com/IMProject/IMUtility.git +[submodule "libs/base64-tl"] + path = libs/base64-tl + url = git@github.com:tvercaut/base64.git +[submodule "libs/base64pp"] + path = libs/base64pp + url = git@github.com:matheusgomes28/base64pp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index eaacdf5..5cdb5e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.25) -project(base64-banchmark) +project(base64-benchmark) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_BUILD_TYPE Release) @@ -24,6 +24,16 @@ set_target_properties(gtest_main PROPERTIES CXX_CLANG_TIDY "") set_target_properties(gmock PROPERTIES CXX_CLANG_TIDY "") set_target_properties(gmock_main PROPERTIES CXX_CLANG_TIDY "") +# Get base64pp +#FetchContent_Declare( +# base64pp +# GIT_REPOSITORY https://github.com/google/googletest.git +# GIT_TAG 750d67d809700ae8fca6d610f7b41b71aa161808 +# SYSTEM +#) +#FetchContent_MakeAvailable(base64pp) +add_subdirectory(./libs/base64pp) + include_directories(libs) @@ -31,6 +41,8 @@ aux_source_directory(./src/ CTR_SOURCES) aux_source_directory(./src/adp-gmbh.ch CTR_SOURCES) aux_source_directory(./src/apache CTR_SOURCES) aux_source_directory(./src/arduino CTR_SOURCES) +aux_source_directory(./src/base64pp CTR_SOURCES) +aux_source_directory(./src/base64-tl CTR_SOURCES) aux_source_directory(./src/DaedalusAlpha CTR_SOURCES) aux_source_directory(./src/ElegantDice CTR_SOURCES) aux_source_directory(./src/gnome CTR_SOURCES) @@ -50,7 +62,7 @@ aux_source_directory(./src/A.Hristov CTR_SOURCES) aux_source_directory(./src/tomykaria CTR_SOURCES) aux_source_directory(./src/stov-180947 CTR_SOURCES) aux_source_directory(./src/libb64/libb64/src C_SOURCES) -aux_source_directory(./src/picobase64 C_SOURCES) +aux_source_directory(./src/picobase64 CTR_SOURCES) aux_source_directory(./libs/chromium/modp_b64 CTR_SOURCES) aux_source_directory(./src/modp_b64_chromium CTR_SOURCES) @@ -75,4 +87,6 @@ set_source_files_properties( ${CTR_SOURCES} PROPERTIES LANGUAGE CXX ) set_source_files_properties( ${C_SOURCES} PROPERTIES LANGUAGE C ) add_executable(${PROJECT_NAME} ${CTR_SOURCES} ${C_SOURCES}) -target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gtest GTest::gtest_main) +target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gtest GTest::gtest_main base64pp) + +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) diff --git a/libs/base64-tl b/libs/base64-tl new file mode 160000 index 0000000..fd33822 --- /dev/null +++ b/libs/base64-tl @@ -0,0 +1 @@ +Subproject commit fd33822a6e80022bbde181210c6b138928f7c351 diff --git a/libs/base64pp b/libs/base64pp new file mode 160000 index 0000000..432c944 --- /dev/null +++ b/libs/base64pp @@ -0,0 +1 @@ +Subproject commit 432c94478fac1ab8b21beef9376b46bee20d8a5d diff --git a/src/base64-tl/test_base64-tl.cpp b/src/base64-tl/test_base64-tl.cpp new file mode 100644 index 0000000..2ee18db --- /dev/null +++ b/src/base64-tl/test_base64-tl.cpp @@ -0,0 +1,20 @@ +#include "../Base64SurveyRegistry.hpp" +#include +#include "../libs/base64-tl/include/base64.hpp" + + +struct base64tl +{ + std::string encode(const std::string& bytes) + { + return base64::to_base64(bytes); + } + + std::string decode(const std::string& base64) + { + return base64::from_base64(base64); + } +}; + +BASE64_REGISTER_ENCODER(base64tl); +BASE64_REGISTER_DECODER(base64tl); diff --git a/src/base64pp/test_base64pp.cpp b/src/base64pp/test_base64pp.cpp new file mode 100644 index 0000000..fb01e3c --- /dev/null +++ b/src/base64pp/test_base64pp.cpp @@ -0,0 +1,22 @@ +#include "../Base64SurveyRegistry.hpp" +#include +#include "../libs/base64pp/base64pp/include/base64pp/base64pp.h" + + +struct base64ppwrap +{ + std::string encode(const std::string& bytes) + { + return base64pp::encode_str(bytes); + } + + std::string decode(const std::string& base64) + { + auto const decoded_bytes = base64pp::decode(base64); + if (!decoded_bytes) throw std::runtime_error{"Invalid base64"}; + return std::string(decoded_bytes->begin(), decoded_bytes->end()); + } +}; + +BASE64_REGISTER_ENCODER(base64ppwrap); +BASE64_REGISTER_DECODER(base64ppwrap); diff --git a/src/main.cpp b/src/main.cpp index 92983ea..4816996 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,10 +31,11 @@ int main(int argc, char *argv[]) #endif // _WIN32 // Run smoke tests on each implementation + int result = EXIT_SUCCESS; { - int result = Base64SurveyTests::RunTests(argc + 1, argv); - cout << "Press enter to continue." << endl; - getchar(); + result = Base64SurveyTests::RunTests(argc + 1, argv); + //cout << "Press enter to continue." << endl; + //getchar(); } // Profile the encoders @@ -77,7 +78,7 @@ int main(int argc, char *argv[]) cout << "Saved decoder report to " + savedPath; } - cout << "Press enter to continue." << endl; - getchar(); - return 0; + //cout << "Press enter to continue." << endl; + //getchar(); + return result; } From a946de69a0ce1dc5683bc28d3d814687edba7124 Mon Sep 17 00:00:00 2001 From: Tom Vercauteren Date: Sun, 18 Feb 2024 14:42:48 +0100 Subject: [PATCH 3/7] trying to fix CI by cloning submodules --- .github/workflows/cmake.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 349150f..c174b6c 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -17,6 +17,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: 'true' - name: Install optional tools (clang-tidy) if: matrix.os == 'ubuntu-latest' From f8ee72d0584186186db2475092cf3481b5f4ea25 Mon Sep 17 00:00:00 2001 From: Tom Vercauteren Date: Sun, 18 Feb 2024 14:49:29 +0100 Subject: [PATCH 4/7] run CI in release mode and run test in verbose mode to see benchmark results on the CI machines --- .github/workflows/cmake.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c174b6c..4d744f2 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -4,7 +4,7 @@ on: [push, pull_request] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: RelWithDebInfo + BUILD_TYPE: Release jobs: build: @@ -20,10 +20,6 @@ jobs: with: submodules: 'true' - - name: Install optional tools (clang-tidy) - if: matrix.os == 'ubuntu-latest' - run: sudo apt-get install -y clang-tidy - - name: Configure CMake # Configure CMake in a 'build' subdirectory. # `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. @@ -38,5 +34,5 @@ jobs: working-directory: ${{github.workspace}}/build # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure + run: ctest -C ${{env.BUILD_TYPE}} --verbose From f7a01170641d94fc58ae18050278503418bc81de Mon Sep 17 00:00:00 2001 From: Tom Vercauteren Date: Mon, 19 Feb 2024 10:58:32 +0100 Subject: [PATCH 5/7] remove spurious comment --- CMakeLists.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cdb5e5..e1252a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,17 +24,8 @@ set_target_properties(gtest_main PROPERTIES CXX_CLANG_TIDY "") set_target_properties(gmock PROPERTIES CXX_CLANG_TIDY "") set_target_properties(gmock_main PROPERTIES CXX_CLANG_TIDY "") -# Get base64pp -#FetchContent_Declare( -# base64pp -# GIT_REPOSITORY https://github.com/google/googletest.git -# GIT_TAG 750d67d809700ae8fca6d610f7b41b71aa161808 -# SYSTEM -#) -#FetchContent_MakeAvailable(base64pp) add_subdirectory(./libs/base64pp) - include_directories(libs) aux_source_directory(./src/ CTR_SOURCES) From c2b34a07cdff911855c36991605e545e6e842f34 Mon Sep 17 00:00:00 2001 From: Tom Vercauteren Date: Tue, 5 Mar 2024 21:31:23 +0000 Subject: [PATCH 6/7] adding SIMD implementation from aklomp --- .gitmodules | 6 +- CMakeLists.txt | 4 +- README.md | 31 +- libs/base64-aklomp | 1 + libs/base64-tl | 2 +- result/result/decode-clang15.js | 421 +++++++++++++++++++++++ result/result/encode-clang15.js | 421 +++++++++++++++++++++++ src/base64-aklomp/test_base64-aklomp.cpp | 40 +++ 8 files changed, 908 insertions(+), 18 deletions(-) create mode 160000 libs/base64-aklomp create mode 100644 result/result/decode-clang15.js create mode 100644 result/result/encode-clang15.js create mode 100644 src/base64-aklomp/test_base64-aklomp.cpp diff --git a/.gitmodules b/.gitmodules index 1074144..84dd219 100644 --- a/.gitmodules +++ b/.gitmodules @@ -54,7 +54,11 @@ url = https://github.com/IMProject/IMUtility.git [submodule "libs/base64-tl"] path = libs/base64-tl - url = git@github.com:tvercaut/base64.git + url = git@github.com:tobiaslocker/base64.git + branch = master [submodule "libs/base64pp"] path = libs/base64pp url = git@github.com:matheusgomes28/base64pp.git +[submodule "libs/base64-aklomp"] + path = libs/base64-aklomp + url = git@github.com:aklomp/base64.git diff --git a/CMakeLists.txt b/CMakeLists.txt index e1252a7..389afc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ set_target_properties(gmock PROPERTIES CXX_CLANG_TIDY "") set_target_properties(gmock_main PROPERTIES CXX_CLANG_TIDY "") add_subdirectory(./libs/base64pp) +add_subdirectory(./libs/base64-aklomp) include_directories(libs) @@ -33,6 +34,7 @@ aux_source_directory(./src/adp-gmbh.ch CTR_SOURCES) aux_source_directory(./src/apache CTR_SOURCES) aux_source_directory(./src/arduino CTR_SOURCES) aux_source_directory(./src/base64pp CTR_SOURCES) +aux_source_directory(./src/base64-aklomp CTR_SOURCES) aux_source_directory(./src/base64-tl CTR_SOURCES) aux_source_directory(./src/DaedalusAlpha CTR_SOURCES) aux_source_directory(./src/ElegantDice CTR_SOURCES) @@ -78,6 +80,6 @@ set_source_files_properties( ${CTR_SOURCES} PROPERTIES LANGUAGE CXX ) set_source_files_properties( ${C_SOURCES} PROPERTIES LANGUAGE C ) add_executable(${PROJECT_NAME} ${CTR_SOURCES} ${C_SOURCES}) -target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gtest GTest::gtest_main base64pp) +target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gtest GTest::gtest_main base64pp base64) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) diff --git a/README.md b/README.md index bd09007..1dbce9d 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,10 @@ # Benchmark results Results for Encoding -[The latest results are here](https://rawcdn.githack.com/gaspardpetit/base64/master/result/result.html) +[The latest results are here](https://rawcdn.githack.com/tvercaut/base64/master/result/result.html) # base64 -Searching the web for a C/C++ base64 implementation yields many results. The first hit as of 2016-12-10 for "c++ base64" are: - - - http://www.adp-gmbh.ch/cpp/common/base64.html (René Nyffenegger's implementation which is often quoted by other implementations) - - http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c which is a stackoverflow entry with multiple "here is my implementation which I think is better" - - http://stackoverflow.com/questions/342409/how-do-i-base64-encode-decode-in-c which holds more code snippets - - http://libb64.sourceforge.net/ which is an opensource implementation claiming to be fast - -Looking further, we find many more: - - - http://web.mit.edu/freebsd/head/contrib/wpa/src/utils/base64.c from Jouni Malinen under BSD license - - https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64 has both a C and C++ implementations +Searching the web for a C/C++ base64 implementation yields many results. How does one chose? @@ -30,6 +20,18 @@ I do not own any of these implementations - make sure you check their respective ## Compared implementations +### base64 (Alfred Klomp) +From https://github.com/aklomp/base64 +A fast C99 implementation with SIMD acceleration + +### base64 (Tobias Locker) +From https://github.com/tobiaslocker/base64 +A c++ single-header library implementing the approach of Nick Galbreath's in `modp_b64` + +### base64 (Mat Gomes) +From https://github.com/matheusgomes28/base64pp +A c++ library written for readibility and supported by a blog post https://matgomes.com/base64-encode-decode-cpp/ + ### adp-gmbh (René Nyffenegger) From http://www.adp-gmbh.ch/cpp/common/base64.html @@ -92,11 +94,10 @@ From https://github.com/tplgy/cppcodec ## Conclusion -- For encoding. the Apache and the Internet Software Consortium versions, written over 15 years ago, beats most of the code snippets posted around - which brings us back to how it is important to look for existing implementations before writing new ones. The ISC implementation comes with an unconvenient license from IBM, however, granting you "immunity from suites under its patents, if any, for the use, sale or manufacture of produces to the extent that such products are used for performing Domain Name System"; +- If you want the fastest implementation, go for base64 (Alfred Klomp) noting that the code base is BSD-2 +- If you want a simple single-header c++ file with good performance, go for base64 (Tobias Locker) - Some other implementations are terrible, the slower ones generally allocate memory dynamically as they convert, even though the output size is deterministic and can be preallocated; - libb64 shows very strange performance results - I get the feeling that they are doing something neat but that I am perhaps not using their code right; - A lot of implementations are available, everyone claims theirs is better. This test shows that unless you measure, you cannot make any claims about the performance of your code; -If you do not need support for line breaks and don't need validation of data integrity, I would recommend using Jouni Malinen or the Apache's implementation for the Encoder, and the modified Polfosol implementation for decoding. - Keep in mind that these results were all obtained using Visual Studio and could differ on another compiler. diff --git a/libs/base64-aklomp b/libs/base64-aklomp new file mode 160000 index 0000000..b20a31a --- /dev/null +++ b/libs/base64-aklomp @@ -0,0 +1 @@ +Subproject commit b20a31a997e0b48274fa09e58b65ee9202531e4f diff --git a/libs/base64-tl b/libs/base64-tl index fd33822..387b32f 160000 --- a/libs/base64-tl +++ b/libs/base64-tl @@ -1 +1 @@ -Subproject commit fd33822a6e80022bbde181210c6b138928f7c351 +Subproject commit 387b32f337b83d358ac1ffe574e596ba99c41d31 diff --git a/result/result/decode-clang15.js b/result/result/decode-clang15.js new file mode 100644 index 0000000..72997ed --- /dev/null +++ b/result/result/decode-clang15.js @@ -0,0 +1,421 @@ +var decode_result_clang15 = [ + {name:'Adition', + values:[ + {len:32,time:0.040943}, + {len:64,time:0.049847}, + {len:128,time:0.0697009}, + {len:256,time:0.134855}, + {len:512,time:0.220096}, + {len:1024,time:0.36352}, + {len:2048,time:0.710797}, + {len:4096,time:1.37226}, + {len:8192,time:2.71851}, + {len:16384,time:5.36397}, + {len:32768,time:10.5761}, + {len:65536,time:21.3417} + ]}, + {name:'AdpGmbh', + values:[ + {len:32,time:0.164044}, + {len:64,time:0.285515}, + {len:128,time:0.539736}, + {len:256,time:1.0414}, + {len:512,time:2.07159}, + {len:1024,time:4.2839}, + {len:2048,time:11.0854}, + {len:4096,time:25.3908}, + {len:8192,time:61.5999}, + {len:16384,time:135.808}, + {len:32768,time:284.875}, + {len:65536,time:571.463} + ]}, + {name:'Ahristov', + values:[ + {len:32,time:0.035806}, + {len:64,time:0.044614}, + {len:128,time:0.0634219}, + {len:256,time:0.124916}, + {len:512,time:0.206863}, + {len:1024,time:0.353306}, + {len:2048,time:0.662751}, + {len:4096,time:1.30533}, + {len:8192,time:2.55267}, + {len:16384,time:5.18979}, + {len:32768,time:10.1121}, + {len:65536,time:20.4915} + ]}, + {name:'Apache', + values:[ + {len:32,time:0.0677889}, + {len:64,time:0.104264}, + {len:128,time:0.20661}, + {len:256,time:0.393763}, + {len:512,time:0.694537}, + {len:1024,time:1.29879}, + {len:2048,time:2.50619}, + {len:4096,time:4.98736}, + {len:8192,time:9.87315}, + {len:16384,time:19.5138}, + {len:32768,time:38.9608}, + {len:65536,time:77.7205} + ]}, + {name:'Arduino', + values:[ + {len:32,time:0.0858189}, + {len:64,time:0.137141}, + {len:128,time:0.265019}, + {len:256,time:0.504409}, + {len:512,time:0.951765}, + {len:1024,time:1.83503}, + {len:2048,time:3.68529}, + {len:4096,time:7.79826}, + {len:8192,time:24.6493}, + {len:16384,time:67.2662}, + {len:32768,time:171.947}, + {len:65536,time:396.923} + ]}, + {name:'Boost', + values:[ + {len:32,time:0.189541}, + {len:64,time:0.352576}, + {len:128,time:0.694856}, + {len:256,time:1.29236}, + {len:512,time:2.41874}, + {len:1024,time:4.61387}, + {len:2048,time:8.9843}, + {len:4096,time:17.7608}, + {len:8192,time:35.3878}, + {len:16384,time:70.7634}, + {len:32768,time:141.496}, + {len:65536,time:281.932} + ]}, + {name:'CppCodec', + values:[ + {len:32,time:0.0821519}, + {len:64,time:0.15347}, + {len:128,time:0.280489}, + {len:256,time:0.538025}, + {len:512,time:1.02297}, + {len:1024,time:2.07042}, + {len:2048,time:3.99723}, + {len:4096,time:8.24713}, + {len:8192,time:16.8723}, + {len:16384,time:31.3824}, + {len:32768,time:61.6934}, + {len:65536,time:126.324} + ]}, + {name:'DaedalusAlpha', + values:[ + {len:32,time:0.128357}, + {len:64,time:0.200362}, + {len:128,time:0.335854}, + {len:256,time:0.648775}, + {len:512,time:1.22239}, + {len:1024,time:2.28389}, + {len:2048,time:4.5889}, + {len:4096,time:8.93634}, + {len:8192,time:17.7375}, + {len:16384,time:35.2132}, + {len:32768,time:70.9806}, + {len:65536,time:144.882} + ]}, + {name:'ElegantDice', + values:[ + {len:32,time:0.12117}, + {len:64,time:0.224964}, + {len:128,time:0.391323}, + {len:256,time:0.75039}, + {len:512,time:1.46419}, + {len:1024,time:2.83188}, + {len:2048,time:5.60673}, + {len:4096,time:11.151}, + {len:8192,time:22.1474}, + {len:16384,time:44.3986}, + {len:32768,time:90.8693}, + {len:65536,time:179.486} + ]}, + {name:'Gnome', + values:[ + {len:32,time:0.0704369}, + {len:64,time:0.104059}, + {len:128,time:0.162626}, + {len:256,time:0.294672}, + {len:512,time:0.530563}, + {len:1024,time:1.01029}, + {len:2048,time:1.9862}, + {len:4096,time:3.97358}, + {len:8192,time:7.76373}, + {len:16384,time:15.1756}, + {len:32768,time:30.4371}, + {len:65536,time:60.4326} + ]}, + {name:'InternetSoftwareConsortium', + values:[ + {len:32,time:0.212803}, + {len:64,time:0.392501}, + {len:128,time:0.782901}, + {len:256,time:1.51041}, + {len:512,time:3.06086}, + {len:1024,time:6.40142}, + {len:2048,time:17.9464}, + {len:4096,time:44.2022}, + {len:8192,time:105.343}, + {len:16384,time:220.493}, + {len:32768,time:470.275}, + {len:65536,time:924.71} + ]}, + {name:'JouniMalinen', + values:[ + {len:32,time:0.0869459}, + {len:64,time:0.141295}, + {len:128,time:0.263996}, + {len:256,time:0.498284}, + {len:512,time:0.925823}, + {len:1024,time:1.79103}, + {len:2048,time:3.49708}, + {len:4096,time:6.97959}, + {len:8192,time:13.8444}, + {len:16384,time:27.7963}, + {len:32768,time:55.7076}, + {len:65536,time:112.386} + ]}, + {name:'LibCurl', + values:[ + {len:32,time:0.550832}, + {len:64,time:0.940171}, + {len:128,time:2.24665}, + {len:256,time:4.28853}, + {len:512,time:8.942}, + {len:1024,time:18.7429}, + {len:2048,time:40.1884}, + {len:4096,time:84.0794}, + {len:8192,time:171.305}, + {len:16384,time:349.676}, + {len:32768,time:724.658}, + {len:65536,time:1464.2} + ]}, + {name:'Libb64', + values:[ + {len:32,time:0.3156}, + {len:64,time:0.412922}, + {len:128,time:0.557101}, + {len:256,time:0.882102}, + {len:512,time:1.35043}, + {len:1024,time:2.18145}, + {len:2048,time:3.89451}, + {len:4096,time:7.27787}, + {len:8192,time:14.0309}, + {len:16384,time:28.108}, + {len:32768,time:55.3265}, + {len:65536,time:110.067} + ]}, + {name:'LihO', + values:[ + {len:32,time:0.227035}, + {len:64,time:0.433873}, + {len:128,time:0.81408}, + {len:256,time:1.56645}, + {len:512,time:3.16019}, + {len:1024,time:7.28602}, + {len:2048,time:20.5154}, + {len:4096,time:46.4798}, + {len:8192,time:106.263}, + {len:16384,time:227.495}, + {len:32768,time:463.759}, + {len:65536,time:929.859} + ]}, + {name:'ManuelMartinez', + values:[ + {len:32,time:0.162421}, + {len:64,time:0.273901}, + {len:128,time:0.467821}, + {len:256,time:0.839745}, + {len:512,time:1.50314}, + {len:1024,time:2.76884}, + {len:2048,time:5.35998}, + {len:4096,time:10.3961}, + {len:8192,time:20.5612}, + {len:16384,time:40.4407}, + {len:32768,time:81.5968}, + {len:65536,time:162.73} + ]}, + {name:'ModpB64Chromium', + values:[ + {len:32,time:0.039796}, + {len:64,time:0.043703}, + {len:128,time:0.0633759}, + {len:256,time:0.128033}, + {len:512,time:0.216385}, + {len:1024,time:0.359094}, + {len:2048,time:0.681897}, + {len:4096,time:1.32104}, + {len:8192,time:2.60517}, + {len:16384,time:5.16858}, + {len:32768,time:10.4952}, + {len:65536,time:20.695} + ]}, + {name:'NibbleAndAHalf', + values:[ + {len:32,time:0.039883}, + {len:64,time:0.047864}, + {len:128,time:0.0697229}, + {len:256,time:0.135285}, + {len:512,time:0.217921}, + {len:1024,time:0.368871}, + {len:2048,time:0.706977}, + {len:4096,time:1.38485}, + {len:8192,time:2.72313}, + {len:16384,time:5.37164}, + {len:32768,time:10.7456}, + {len:65536,time:21.3653} + ]}, + {name:'Polfosol', + values:[ + {len:32,time:0.0663159}, + {len:64,time:0.0551449}, + {len:128,time:0.107561}, + {len:256,time:0.175219}, + {len:512,time:0.331074}, + {len:1024,time:0.540137}, + {len:2048,time:1.12684}, + {len:4096,time:2.0918}, + {len:8192,time:4.34726}, + {len:16384,time:8.25373}, + {len:32768,time:17.9611}, + {len:65536,time:33.1308} + ]}, + {name:'Polfosol_mod', + values:[ + {len:32,time:0.04875}, + {len:64,time:0.0605329}, + {len:128,time:0.0903049}, + {len:256,time:0.176904}, + {len:512,time:0.310195}, + {len:1024,time:0.552028}, + {len:2048,time:1.07204}, + {len:4096,time:2.10158}, + {len:8192,time:4.14019}, + {len:16384,time:8.02203}, + {len:32768,time:16.2613}, + {len:65536,time:33.3662} + ]}, + {name:'TomyKaria', + values:[ + {len:32,time:0.0623689}, + {len:64,time:0.0859019}, + {len:128,time:0.142969}, + {len:256,time:0.267289}, + {len:512,time:0.477227}, + {len:1024,time:0.861879}, + {len:2048,time:1.68845}, + {len:4096,time:3.25478}, + {len:8192,time:6.65736}, + {len:16384,time:12.8371}, + {len:32768,time:26.4564}, + {len:65536,time:51.8805} + ]}, + {name:'User152949', + values:[ + {len:32,time:0.858055}, + {len:64,time:1.56842}, + {len:128,time:2.87963}, + {len:256,time:5.55515}, + {len:512,time:10.9731}, + {len:1024,time:21.7606}, + {len:2048,time:43.1445}, + {len:4096,time:84.8392}, + {len:8192,time:167.195}, + {len:16384,time:334.749}, + {len:32768,time:681.156}, + {len:65536,time:1348.05} + ]}, + {name:'WikibooksOrgC', + values:[ + {len:32,time:0.0633579}, + {len:64,time:0.0940729}, + {len:128,time:0.182825}, + {len:256,time:0.32276}, + {len:512,time:0.583343}, + {len:1024,time:1.10679}, + {len:2048,time:2.15274}, + {len:4096,time:4.27414}, + {len:8192,time:8.4291}, + {len:16384,time:16.8385}, + {len:32768,time:33.9609}, + {len:65536,time:68.1307} + ]}, + {name:'WikibooksOrgCpp', + values:[ + {len:32,time:0.156931}, + {len:64,time:0.274685}, + {len:128,time:0.469939}, + {len:256,time:0.906653}, + {len:512,time:1.756}, + {len:1024,time:3.5449}, + {len:2048,time:8.08801}, + {len:4096,time:20.3806}, + {len:8192,time:49.9941}, + {len:16384,time:107.411}, + {len:32768,time:224.04}, + {len:65536,time:453.898} + ]}, + {name:'base64aklomp', + values:[ + {len:32,time:0.038873}, + {len:64,time:0.037051}, + {len:128,time:0.045535}, + {len:256,time:0.0809239}, + {len:512,time:0.108601}, + {len:1024,time:0.142789}, + {len:2048,time:0.258632}, + {len:4096,time:0.46983}, + {len:8192,time:0.948515}, + {len:16384,time:1.86672}, + {len:32768,time:3.84466}, + {len:65536,time:7.42992} + ]}, + {name:'base64ppwrap', + values:[ + {len:32,time:0.129426}, + {len:64,time:0.143011}, + {len:128,time:0.227899}, + {len:256,time:0.405935}, + {len:512,time:0.723471}, + {len:1024,time:1.23979}, + {len:2048,time:2.30418}, + {len:4096,time:4.53136}, + {len:8192,time:8.7463}, + {len:16384,time:17.1837}, + {len:32768,time:36.7896}, + {len:65536,time:68.8376} + ]}, + {name:'base64tl', + values:[ + {len:32,time:0.04008}, + {len:64,time:0.045201}, + {len:128,time:0.0650329}, + {len:256,time:0.130864}, + {len:512,time:0.213696}, + {len:1024,time:0.342892}, + {len:2048,time:0.662415}, + {len:4096,time:1.30641}, + {len:8192,time:2.58691}, + {len:16384,time:5.1293}, + {len:32768,time:10.3509}, + {len:65536,time:20.912} + ]}, + {name:'picobase64', + values:[ + {len:32,time:0.040458}, + {len:64,time:0.048277}, + {len:128,time:0.0706409}, + {len:256,time:0.138316}, + {len:512,time:0.228083}, + {len:1024,time:0.372479}, + {len:2048,time:0.698425}, + {len:4096,time:1.36978}, + {len:8192,time:2.69311}, + {len:16384,time:5.39095}, + {len:32768,time:10.7507}, + {len:65536,time:21.5984} + ]}] diff --git a/result/result/encode-clang15.js b/result/result/encode-clang15.js new file mode 100644 index 0000000..27381d1 --- /dev/null +++ b/result/result/encode-clang15.js @@ -0,0 +1,421 @@ +var encode_result_clang15 = [ + {name:'Adition', + values:[ + {len:32,time:0.0671189}, + {len:64,time:0.0565679}, + {len:128,time:0.0809659}, + {len:256,time:0.16361}, + {len:512,time:0.263931}, + {len:1024,time:0.461093}, + {len:2048,time:0.877786}, + {len:4096,time:1.73234}, + {len:8192,time:3.40431}, + {len:16384,time:6.77351}, + {len:32768,time:13.6441}, + {len:65536,time:27.085} + ]}, + {name:'AdpGmbh', + values:[ + {len:32,time:0.118875}, + {len:64,time:0.205951}, + {len:128,time:0.361243}, + {len:256,time:0.716568}, + {len:512,time:1.39271}, + {len:1024,time:2.7002}, + {len:2048,time:5.33872}, + {len:4096,time:10.7133}, + {len:8192,time:21.5321}, + {len:16384,time:42.7955}, + {len:32768,time:86.1287}, + {len:65536,time:177.254} + ]}, + {name:'Ahristov', + values:[ + {len:32,time:0.044521}, + {len:64,time:0.044057}, + {len:128,time:0.0647299}, + {len:256,time:0.125885}, + {len:512,time:0.222958}, + {len:1024,time:0.36926}, + {len:2048,time:0.692344}, + {len:4096,time:1.36571}, + {len:8192,time:2.69132}, + {len:16384,time:5.33808}, + {len:32768,time:11.0047}, + {len:65536,time:22.3588} + ]}, + {name:'Apache', + values:[ + {len:32,time:0.045205}, + {len:64,time:0.0535839}, + {len:128,time:0.0791909}, + {len:256,time:0.152921}, + {len:512,time:0.265739}, + {len:1024,time:0.459041}, + {len:2048,time:0.886272}, + {len:4096,time:1.8029}, + {len:8192,time:3.50203}, + {len:16384,time:6.95923}, + {len:32768,time:13.6719}, + {len:65536,time:27.7228} + ]}, + {name:'Arduino', + values:[ + {len:32,time:0.0682099}, + {len:64,time:0.0961129}, + {len:128,time:0.158888}, + {len:256,time:0.282659}, + {len:512,time:0.495433}, + {len:1024,time:0.894037}, + {len:2048,time:1.73297}, + {len:4096,time:3.43985}, + {len:8192,time:6.74442}, + {len:16384,time:13.5216}, + {len:32768,time:26.9406}, + {len:65536,time:54.2755} + ]}, + {name:'Boost', + values:[ + {len:32,time:0.283907}, + {len:64,time:0.480338}, + {len:128,time:0.890632}, + {len:256,time:1.73273}, + {len:512,time:3.28138}, + {len:1024,time:6.29559}, + {len:2048,time:12.3873}, + {len:4096,time:24.6767}, + {len:8192,time:48.8075}, + {len:16384,time:96.325}, + {len:32768,time:192.559}, + {len:65536,time:384.515} + ]}, + {name:'CppCodec', + values:[ + {len:32,time:0.0968649}, + {len:64,time:0.179504}, + {len:128,time:0.339296}, + {len:256,time:0.722922}, + {len:512,time:1.39297}, + {len:1024,time:2.63106}, + {len:2048,time:5.218}, + {len:4096,time:10.3957}, + {len:8192,time:20.835}, + {len:16384,time:42.3628}, + {len:32768,time:82.1373}, + {len:65536,time:167.466} + ]}, + {name:'DaedalusAlpha', + values:[ + {len:32,time:0.1202}, + {len:64,time:0.203249}, + {len:128,time:0.363734}, + {len:256,time:0.727218}, + {len:512,time:1.40579}, + {len:1024,time:2.71285}, + {len:2048,time:5.37688}, + {len:4096,time:10.7327}, + {len:8192,time:21.3116}, + {len:16384,time:42.5802}, + {len:32768,time:85.4791}, + {len:65536,time:169.871} + ]}, + {name:'ElegantDice', + values:[ + {len:32,time:0.11868}, + {len:64,time:0.19884}, + {len:128,time:0.361047}, + {len:256,time:0.734891}, + {len:512,time:1.40525}, + {len:1024,time:2.69528}, + {len:2048,time:5.36113}, + {len:4096,time:10.7622}, + {len:8192,time:21.1552}, + {len:16384,time:43.2516}, + {len:32768,time:85.802}, + {len:65536,time:173.943} + ]}, + {name:'Gnome', + values:[ + {len:32,time:0.0702969}, + {len:64,time:0.0673569}, + {len:128,time:0.0973389}, + {len:256,time:0.195353}, + {len:512,time:0.294014}, + {len:1024,time:0.446534}, + {len:2048,time:0.836161}, + {len:4096,time:1.60408}, + {len:8192,time:3.05986}, + {len:16384,time:6.11799}, + {len:32768,time:12.8392}, + {len:65536,time:23.6278} + ]}, + {name:'InternetSoftwareConsortium', + values:[ + {len:32,time:0.047462}, + {len:64,time:0.0516839}, + {len:128,time:0.0840749}, + {len:256,time:0.147781}, + {len:512,time:0.244392}, + {len:1024,time:0.402109}, + {len:2048,time:0.767901}, + {len:4096,time:1.50019}, + {len:8192,time:2.92326}, + {len:16384,time:5.87704}, + {len:32768,time:11.6212}, + {len:65536,time:23.4548} + ]}, + {name:'JouniMalinen', + values:[ + {len:32,time:0.042183}, + {len:64,time:0.0517289}, + {len:128,time:0.0757039}, + {len:256,time:0.147958}, + {len:512,time:0.252228}, + {len:1024,time:0.438701}, + {len:2048,time:0.840713}, + {len:4096,time:1.65303}, + {len:8192,time:3.27864}, + {len:16384,time:6.50268}, + {len:32768,time:13.095}, + {len:65536,time:26.1313} + ]}, + {name:'LibCurl', + values:[ + {len:32,time:0.66295}, + {len:64,time:1.25688}, + {len:128,time:2.45772}, + {len:256,time:4.89094}, + {len:512,time:9.65999}, + {len:1024,time:19.1836}, + {len:2048,time:38.3268}, + {len:4096,time:76.426}, + {len:8192,time:152.894}, + {len:16384,time:304.801}, + {len:32768,time:610.73}, + {len:65536,time:1229.13} + ]}, + {name:'Libb64', + values:[ + {len:32,time:0.278167}, + {len:64,time:0.369349}, + {len:128,time:0.471664}, + {len:256,time:0.697452}, + {len:512,time:0.995377}, + {len:1024,time:1.49723}, + {len:2048,time:2.48532}, + {len:4096,time:4.48533}, + {len:8192,time:8.45209}, + {len:16384,time:16.4087}, + {len:32768,time:31.9856}, + {len:65536,time:63.5709} + ]}, + {name:'LihO', + values:[ + {len:32,time:0.104413}, + {len:64,time:0.207129}, + {len:128,time:0.427229}, + {len:256,time:0.806385}, + {len:512,time:1.53313}, + {len:1024,time:2.94859}, + {len:2048,time:5.6891}, + {len:4096,time:11.2044}, + {len:8192,time:22.2796}, + {len:16384,time:43.9963}, + {len:32768,time:88.2007}, + {len:65536,time:177.413} + ]}, + {name:'ManuelMartinez', + values:[ + {len:32,time:0.104551}, + {len:64,time:0.229142}, + {len:128,time:0.42657}, + {len:256,time:0.827372}, + {len:512,time:1.57313}, + {len:1024,time:2.99003}, + {len:2048,time:5.75803}, + {len:4096,time:11.2471}, + {len:8192,time:22.3342}, + {len:16384,time:44.0715}, + {len:32768,time:88.5121}, + {len:65536,time:177.352} + ]}, + {name:'ModpB64Chromium', + values:[ + {len:32,time:0.038172}, + {len:64,time:0.046197}, + {len:128,time:0.0665259}, + {len:256,time:0.131866}, + {len:512,time:0.22263}, + {len:1024,time:0.377365}, + {len:2048,time:0.713989}, + {len:4096,time:1.40735}, + {len:8192,time:2.77876}, + {len:16384,time:5.50427}, + {len:32768,time:11.102}, + {len:65536,time:22.6119} + ]}, + {name:'NibbleAndAHalf', + values:[ + {len:32,time:0.042829}, + {len:64,time:0.0516319}, + {len:128,time:0.0732469}, + {len:256,time:0.147227}, + {len:512,time:0.237023}, + {len:1024,time:0.392268}, + {len:2048,time:0.750181}, + {len:4096,time:1.48085}, + {len:8192,time:2.91082}, + {len:16384,time:5.73878}, + {len:32768,time:11.5724}, + {len:65536,time:23.2585} + ]}, + {name:'Omnifarious', + values:[ + {len:32,time:0.0625859}, + {len:64,time:0.0886349}, + {len:128,time:0.158315}, + {len:256,time:0.312658}, + {len:512,time:0.567251}, + {len:1024,time:1.07674}, + {len:2048,time:2.10213}, + {len:4096,time:4.17375}, + {len:8192,time:8.25227}, + {len:16384,time:16.5232}, + {len:32768,time:33.3122}, + {len:65536,time:66.619} + ]}, + {name:'Polfosol', + values:[ + {len:32,time:0.04475}, + {len:64,time:0.0599699}, + {len:128,time:0.0925339}, + {len:256,time:0.181734}, + {len:512,time:0.322785}, + {len:1024,time:0.575796}, + {len:2048,time:1.13219}, + {len:4096,time:2.21602}, + {len:8192,time:4.38495}, + {len:16384,time:8.70065}, + {len:32768,time:17.6201}, + {len:65536,time:35.5906} + ]}, + {name:'TomyKaria', + values:[ + {len:32,time:0.0742179}, + {len:64,time:0.0825729}, + {len:128,time:0.127881}, + {len:256,time:0.269178}, + {len:512,time:0.459665}, + {len:1024,time:0.771788}, + {len:2048,time:1.47411}, + {len:4096,time:2.88193}, + {len:8192,time:5.66237}, + {len:16384,time:11.3818}, + {len:32768,time:22.8797}, + {len:65536,time:45.3012} + ]}, + {name:'User152949', + values:[ + {len:32,time:0.865997}, + {len:64,time:1.59274}, + {len:128,time:2.94931}, + {len:256,time:5.65406}, + {len:512,time:11.1035}, + {len:1024,time:21.6288}, + {len:2048,time:42.8165}, + {len:4096,time:85.1754}, + {len:8192,time:169.354}, + {len:16384,time:338.242}, + {len:32768,time:674.327}, + {len:65536,time:1346.17} + ]}, + {name:'WikibooksOrgC', + values:[ + {len:32,time:0.0633169}, + {len:64,time:0.0797009}, + {len:128,time:0.116242}, + {len:256,time:0.214178}, + {len:512,time:0.365681}, + {len:1024,time:0.656165}, + {len:2048,time:1.29562}, + {len:4096,time:2.52898}, + {len:8192,time:5.0175}, + {len:16384,time:9.97556}, + {len:32768,time:20.0885}, + {len:65536,time:40.212} + ]}, + {name:'WikibooksOrgCpp', + values:[ + {len:32,time:0.201382}, + {len:64,time:0.330531}, + {len:128,time:0.638103}, + {len:256,time:1.21391}, + {len:512,time:2.32954}, + {len:1024,time:4.53938}, + {len:2048,time:9.00319}, + {len:4096,time:17.9019}, + {len:8192,time:36.035}, + {len:16384,time:72.0261}, + {len:32768,time:143.231}, + {len:65536,time:286.9} + ]}, + {name:'base64aklomp', + values:[ + {len:32,time:0.038797}, + {len:64,time:0.03713}, + {len:128,time:0.039575}, + {len:256,time:0.0683779}, + {len:512,time:0.0862079}, + {len:1024,time:0.0989529}, + {len:2048,time:0.168166}, + {len:4096,time:0.288333}, + {len:8192,time:0.569746}, + {len:16384,time:1.1105}, + {len:32768,time:2.23712}, + {len:65536,time:4.38443} + ]}, + {name:'base64ppwrap', + values:[ + {len:32,time:0.0999129}, + {len:64,time:0.182054}, + {len:128,time:0.349632}, + {len:256,time:0.732646}, + {len:512,time:1.41561}, + {len:1024,time:2.70745}, + {len:2048,time:5.409}, + {len:4096,time:10.8321}, + {len:8192,time:21.6739}, + {len:16384,time:43.5271}, + {len:32768,time:86.6746}, + {len:65536,time:184.826} + ]}, + {name:'base64tl', + values:[ + {len:32,time:0.038122}, + {len:64,time:0.043677}, + {len:128,time:0.0654209}, + {len:256,time:0.125427}, + {len:512,time:0.211876}, + {len:1024,time:0.359368}, + {len:2048,time:0.683216}, + {len:4096,time:1.33216}, + {len:8192,time:2.64347}, + {len:16384,time:5.20651}, + {len:32768,time:10.4842}, + {len:65536,time:21.3204} + ]}, + {name:'picobase64', + values:[ + {len:32,time:0.045381}, + {len:64,time:0.0538589}, + {len:128,time:0.0811759}, + {len:256,time:0.155492}, + {len:512,time:0.264038}, + {len:1024,time:0.458904}, + {len:2048,time:0.879947}, + {len:4096,time:1.73512}, + {len:8192,time:3.37631}, + {len:16384,time:6.69841}, + {len:32768,time:13.5186}, + {len:65536,time:27.64} + ]}] diff --git a/src/base64-aklomp/test_base64-aklomp.cpp b/src/base64-aklomp/test_base64-aklomp.cpp new file mode 100644 index 0000000..64516ee --- /dev/null +++ b/src/base64-aklomp/test_base64-aklomp.cpp @@ -0,0 +1,40 @@ +#include "../Base64SurveyRegistry.hpp" +#include +#include "../libs/base64-aklomp/include/libbase64.h" + + +struct base64aklomp +{ + std::string encode(const std::string& bytes) + { + size_t outlen = (4*bytes.length() + 3 - 1) / 3; + size_t margin = 10; + int flags = 0; // the default implementation path + //int flags = BASE64_FORCE_PLAIN; // the slower implementation path + + std::string outstr(outlen+margin, '\0'); + base64_encode(bytes.c_str(), bytes.length(), outstr.data(), &outlen, flags); + outstr.resize(outlen); + return outstr; + } + + std::string decode(const std::string& base64) + { + size_t outlen = (3*base64.length() + 4 - 1) / 4; + size_t margin = 10; + int flags = 0; // the default implementation path + //int flags = BASE64_FORCE_PLAIN; // the slower implementation path + + std::string outstr(outlen+margin, '\0'); + const int outval = base64_decode(base64.c_str(), base64.length(), outstr.data(), &outlen, flags); + if(outval != 1) + { + throw std::runtime_error("base64_decode went wrong with output value: " + std::to_string(outval)); + } + outstr.resize(outlen); + return outstr; + } +}; + +BASE64_REGISTER_ENCODER(base64aklomp); +BASE64_REGISTER_DECODER(base64aklomp); From 323811e592a9e5d8df37ce1c10a073f2d3a110e2 Mon Sep 17 00:00:00 2001 From: Tom Vercauteren Date: Tue, 5 Mar 2024 21:38:30 +0000 Subject: [PATCH 7/7] trying to fix result table --- README.md | 2 +- result/result.html | 94 +++++++++------------------------------------- 2 files changed, 18 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index 1dbce9d..f84bf40 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Benchmark results Results for Encoding -[The latest results are here](https://rawcdn.githack.com/tvercaut/base64/master/result/result.html) +[The latest results are here](https://raw.githack.com/tvercaut/base64-benchmark/master/result/result.html) # base64 diff --git a/result/result.html b/result/result.html index 3b25ca8..d327475 100644 --- a/result/result.html +++ b/result/result.html @@ -39,10 +39,8 @@ - - - - + +

- Benchmark results (Clang 12 / AMD5700G) + Benchmark results (Clang 15)

Encode Results

- +
@@ -236,12 +222,12 @@

Encode Results

- +

Decode Results

-
+
@@ -250,31 +236,12 @@

Decode Results

- +

Encode + Decode Results

-
- - - - -
-

- -

- -

- -
-

- Benchmark results (MSVC 2019/19.28.29335 x64 / Intel Xeon W-2133 @ 3.6GHz) -

-
-

-

Encode Results

- +
@@ -283,36 +250,9 @@

Encode Results

- +

-

-

Decode Results

-
- - - - -
-

- -

- -

- -

-

Encode + Decode Results

- - - - - -
-

- -

- -