Skip to content

Commit

Permalink
✨ ztd.text and friend benchmarks, promotion of text_encoding_id
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhD committed Sep 13, 2022
1 parent 3cc3864 commit cd93367
Show file tree
Hide file tree
Showing 52 changed files with 4,396 additions and 84 deletions.
37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ FetchContent_Declare(ztd.static_containers
FetchContent_MakeAvailable(ztd.static_containers)

# ztd.cuneicode
set(ZTD_CUNEICODE_SIMDUTF_SHARED ${ZTD_TEXT_BENCHMARKS})
FetchContent_Declare(ztd.cuneicode
GIT_REPOSITORY https://github.com/soasis/cuneicode.git
GIT_TAG main)
Expand All @@ -145,6 +146,10 @@ FetchContent_Declare(ztd.platform
GIT_TAG main)
FetchContent_MakeAvailable(ztd.platform)

if (ZTD_TEXT_BENCHAMRKS OR ZTD_TEXT_GENERATE_SINGLE OR ZTD_TEXT_DOCUMENTATION)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
endif()

# Main library declarations
file(GLOB_RECURSE ztd.text.includes CONFIGURE_DEPENDS include/*.hpp)

Expand Down Expand Up @@ -185,6 +190,38 @@ if(ZTD_TEXT_GENERATE_SINGLE)
endif()

# # Benchmarks, Tests, Examples and Documentation
# Example and/or benchmark dependencies
if (ZTD_TEXT_EXAMPLES OR ZTD_TEXT_BENCHMARKS)
# # Fetch dependencies for either benchmarks and/or examples
function(simdutf_dependency_jail)
# simdutf
set(SIMDUTF_BENCHMARKS OFF CACHE INTERNAL "")
set(BUILD_TESTING OFF CACHE INTERNAL "")
FetchContent_Declare(
simdutf
GIT_REPOSITORY https://github.com/simdutf/simdutf
)
FetchContent_MakeAvailable(simdutf)
endfunction()
simdutf_dependency_jail()

function(boost_text_dependency_jail)
# boost.text
set(BOOST_TEXT_PERF OFF CACHE INTERNAL "")
set(BOOST_TEXT_EXAMPLES OFF CACHE INTERNAL "")
set(BOOST_TEXT_TESTS OFF CACHE INTERNAL "")
set(BOOST_TEXT_FETCH_BOOST ON CACHE INTERNAL "")
set(BOOST_TEXT_INSTALL OFF CACHE INTERNAL "")
set(BUILD_TESTING OFF CACHE INTERNAL "")
FetchContent_Declare(
boost.text
GIT_REPOSITORY https://github.com/ThePhD/text
)
FetchContent_MakeAvailable(boost.text)
endfunction()
boost_text_dependency_jail()
endif()

if(ZTD_TEXT_TESTS)
include(CTest)
add_subdirectory(tests)
Expand Down
91 changes: 91 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# =============================================================================
#
# ztd.text
# Copyright © 2022-2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
# Contact: opensource@soasis.org
#
# Commercial License Usage
# Licensees holding valid commercial ztd.text licenses may use this file
# in accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Shepherd's Oasis, LLC.
# For licensing terms and conditions see your agreement. For
# further information contact opensource@soasis.org.
#
# Apache License Version 2 Usage
# Alternatively, this file may be used under the terms of Apache License
# Version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# =========================================================================== #

include(FetchContent)
include(GraphBenchmarks)

# # Fetch dependencies
# Google Benchmark
function(googlebenchmark_dependency_jail)
FetchContent_Declare(
googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG 108ca84820dc932957b75e6b31faa6c3cf0aa37a
)
FetchContent_GetProperties(googlebenchmark)

if(NOT googlebenchmark_POPULATED)
FetchContent_Populate(googlebenchmark)
set(BENCHMARK_ENABLE_INSTALL OFF CACHE INTERNAL "")
set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "")
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE INTERNAL "")
set(BENCHMARK_ENABLE_WERROR OFF CACHE INTERNAL "")
set(BENCHMARK_FORCE_WERROR OFF CACHE INTERNAL "")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND WIN32)
# google benchmark is broken, so we need to force HAVE_STD_REGEX to be on for this.
set(HAVE_STD_REGEX ON CACHE INTERNAL "")
endif()
add_subdirectory(${googlebenchmark_SOURCE_DIR} ${googlebenchmark_BINARY_DIR})
endif()
endfunction()
googlebenchmark_dependency_jail()

function (utf8cpp_dependency_jail)
FetchContent_Declare(
utf8cpp
GIT_REPOSITORY https://github.com/nemtrif/utfcpp
)
FetchContent_MakeAvailable(utf8cpp)
endfunction()
utf8cpp_dependency_jail()

function (ctre_dependency_jail)
FetchContent_Declare(
ctre
GIT_REPOSITORY https://github.com/hanickadot/compile-time-regular-expressions
GIT_TAG main
)
FetchContent_MakeAvailable(ctre)
endfunction()
ctre_dependency_jail()

function(ztd_platform_dependency_jail)
# ztd.platform
FetchContent_Declare(
ztd.platform
GIT_REPOSITORY https://github.com/soasis/platform
GIT_TAG main
)
FetchContent_MakeAvailable(ztd.platform)
endfunction()
ztd_platform_dependency_jail()

add_subdirectory(barrier)
add_subdirectory(function_form)
add_subdirectory(speed)
68 changes: 68 additions & 0 deletions benchmarks/barrier/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# =============================================================================
#
# ztd.text
# Copyright © 2022-2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
# Contact: opensource@soasis.org
#
# Commercial License Usage
# Licensees holding valid commercial ztd.text licenses may use this file
# in accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Shepherd's Oasis, LLC.
# For licensing terms and conditions see your agreement. For
# further information contact opensource@soasis.org.
#
# Apache License Version 2 Usage
# Alternatively, this file may be used under the terms of Apache License
# Version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# =========================================================================== #

# # Benchmarks
file(GLOB_RECURSE ztd.text.benchmarks.barrier.sources
LIST_DIRECTORIES FALSE
CONFIGURE_DEPENDS
source/*.c source/*.cpp)

add_library(ztd.text.benchmarks.barrier
SHARED
${ztd.text.benchmarks.barrier.sources}
)
add_library(ztd::cuneicode::benchmarks::barrier
ALIAS
ztd.text.benchmarks.barrier
)
target_compile_definitions(ztd.text.benchmarks.barrier
PRIVATE
ZTD_TEXT_BENCHMARKS_BARRIER_BUILD=1
PUBLIC
ZTD_TEXT_BENCHMARKS_BARRIER_DLL=1
)
target_compile_options(ztd.text.benchmarks.barrier
PRIVATE
${--utf8-literal-encoding}
${--utf8-source-encoding}
${--disable-permissive}
${--updated-cpp-version-flag}
${--warn-pedantic}
${--warn-all}
${--warn-extra}
${--warn-errors})
target_link_libraries(ztd.text.benchmarks.barrier
PRIVATE
ztd::cuneicode
${CMAKE_DL_LIBS}
)
target_include_directories(ztd.text.benchmarks.barrier
PUBLIC
include
)
92 changes: 92 additions & 0 deletions benchmarks/barrier/include/barrier/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// =============================================================================
//
// ztd.idk
// Copyright © 2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
// Contact: opensource@soasis.org
//
// Commercial License Usage
// Licensees holding valid commercial ztd.idk licenses may use this file in
// accordance with the commercial license agreement provided with the
// Software or, alternatively, in accordance with the terms contained in
// a written agreement between you and Shepherd's Oasis, LLC.
// For licensing terms and conditions see your agreement. For
// further information contact opensource@soasis.org.
//
// Apache License Version 2 Usage
// Alternatively, this file may be used under the terms of Apache License
// Version 2.0 (the "License") for non-commercial use; you may not use this
// file except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ============================================================================ //

#pragma once

#ifndef ZTD_TEXT_BENCHMARKS_BARRIER_API_H
#define ZTD_TEXT_BENCHMARKS_BARRIER_API_H

#include <barrier/version.h>

// clang-format off

#if defined(ZTD_TEXT_BENCHMARKS_BARRIER_BUILD)
#if (ZTD_TEXT_BENCHMARKS_BARRIER_BUILD != 0)
#define ZTD_TEXT_BENCHMARKS_BARRIER_BUILD_I_ ZTD_ON
#else
#define ZTD_TEXT_BENCHMARKS_BARRIER_BUILD_I_ ZTD_OFF
#endif
#else
#define ZTD_TEXT_BENCHMARKS_BARRIER_BUILD_I_ ZTD_DEFAULT_OFF
#endif // Building or not

#if defined(ZTD_TEXT_BENCHMARKS_BARRIER_DLL)
#if (ZTD_TEXT_BENCHMARKS_BARRIER_DLL != 0)
#define ZTD_TEXT_BENCHMARKS_BARRIER_DLL_I_ ZTD_ON
#else
#define ZTD_TEXT_BENCHMARKS_BARRIER_DLL_I_ ZTD_ON
#endif
#else
#define ZTD_TEXT_BENCHMARKS_BARRIER_DLL_I_ ZTD_OFF
#endif // Building or not

#if defined(ZTD_TEXT_BENCHMARKS_BARRIER_API_LINKAGE)
#define ZTD_TEXT_BENCHMARKS_BARRIER_API_LINKAGE_I_ ZTD_TEXT_BENCHMARKS_BARRIER_API_LINKAGE
#else
#if ZTD_IS_ON(ZTD_TEXT_BENCHMARKS_BARRIER_DLL)
#if ZTD_IS_ON(ZTD_COMPILER_VCXX) || ZTD_IS_ON(ZTD_PLATFORM_WINDOWS) || ZTD_IS_ON(ZTD_PLATFORM_CYGWIN)
// MSVC Compiler; or, Windows, or Cygwin platforms
#if ZTD_IS_ON(ZTD_TEXT_BENCHMARKS_BARRIER_BUILD)
// Building the library
#if ZTD_IS_ON(ZTD_COMPILER_GCC)
// Using GCC
#define ZTD_TEXT_BENCHMARKS_BARRIER_API_LINKAGE_I_ __attribute__((dllexport))
#else
// Using Clang, MSVC, etc...
#define ZTD_TEXT_BENCHMARKS_BARRIER_API_LINKAGE_I_ __declspec(dllexport)
#endif
#else
#if ZTD_IS_ON(ZTD_COMPILER_GCC)
#define ZTD_TEXT_BENCHMARKS_BARRIER_API_LINKAGE_I_ __attribute__((dllimport))
#else
#define ZTD_TEXT_BENCHMARKS_BARRIER_API_LINKAGE_I_ __declspec(dllimport)
#endif
#endif
#else
#define ZTD_TEXT_BENCHMARKS_BARRIER_API_LINKAGE_I_
#endif
#else
#define ZTD_TEXT_BENCHMARKS_BARRIER_API_LINKAGE_I_
#endif // DLL or not
#endif // Build definitions

// clang-format on

#endif // ZTD_TEXT_BENCHMARKS_BARRIER_API_H
40 changes: 40 additions & 0 deletions benchmarks/barrier/include/barrier/barrier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// ============================================================================
//
// ztd.text
// Copyright © 2022-2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
// Contact: opensource@soasis.org
//
// Commercial License Usage
// Licensees holding valid commercial ztd.text licenses may use this file
// in accordance with the commercial license agreement provided with the
// Software or, alternatively, in accordance with the terms contained in
// a written agreement between you and Shepherd's Oasis, LLC.
// For licensing terms and conditions see your agreement. For
// further information contact opensource@soasis.org.
//
// Apache License Version 2 Usage
// Alternatively, this file may be used under the terms of Apache License
// Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ========================================================================= //

#pragma once

#ifndef ZTD_TEXT_BENCHMARKS_BARRIER_BARRIER_H
#define ZTD_TEXT_BENCHMARKS_BARRIER_BARRIER_H

#include <barrier/version.h>

#include <barrier/convert.h>
#include <barrier/data.h>

#endif // ZTD_TEXT_BENCHMARKS_BARRIER_BARRIER_H

0 comments on commit cd93367

Please sign in to comment.