Skip to content

Commit 30fa1ce

Browse files
committed
✨ new closure benchmarks
1 parent 192bbc6 commit 30fa1ce

39 files changed

Lines changed: 1384 additions & 28 deletions

‎benchmarks/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ google_benchmark_dependency_jail()
6161
# # Benchmarks
6262
# Bit benchmarks
6363
add_subdirectory(bit)
64+
add_subdirectory(closures)

‎benchmarks/bit/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ target_include_directories(ztd.idk.benchmarks.bit PRIVATE
4141
)
4242
target_link_libraries(ztd.idk.benchmarks.bit PRIVATE
4343
ztd::idk
44-
ztd::idk::benchmarks::opaque
44+
ztd::idk::benchmarks::bit::opaque
4545
benchmark
4646
${CMAKE_DL_LIBS}
4747
)

‎benchmarks/bit/opaque/CMakeLists.txt‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,29 @@
2929
# ============================================================================>
3030

3131
# # Opaque Library
32-
file(GLOB_RECURSE ztd.idk.benchmarks.opaque.sources
32+
file(GLOB_RECURSE ztd.idk.benchmarks.bit.opaque.sources
3333
CONFIGURE_DEPENDS
3434
source/**.cpp source/**.c)
3535

36-
add_library(ztd.idk.benchmarks.opaque SHARED ${ztd.idk.benchmarks.opaque.sources})
37-
add_library(ztd::idk::benchmarks::opaque ALIAS ztd.idk.benchmarks.opaque)
38-
target_include_directories(ztd.idk.benchmarks.opaque
36+
add_library(ztd.idk.benchmarks.bit.opaque SHARED ${ztd.idk.benchmarks.bit.opaque.sources})
37+
add_library(ztd::idk::benchmarks::bit::opaque ALIAS ztd.idk.benchmarks.bit.opaque)
38+
target_include_directories(ztd.idk.benchmarks.bit.opaque
3939
PUBLIC
4040
include/
4141
)
42-
target_link_libraries(ztd.idk.benchmarks.opaque PRIVATE
42+
target_link_libraries(ztd.idk.benchmarks.bit.opaque PRIVATE
4343
ztd::idk
4444
${CMAKE_DL_LIBS}
4545
)
46-
target_compile_definitions(ztd.idk.benchmarks.opaque
46+
target_compile_definitions(ztd.idk.benchmarks.bit.opaque
4747
PRIVATE
4848
ZTD_OPAQUE_BUILD=1
4949
)
50-
target_compile_definitions(ztd.idk.benchmarks.opaque
50+
target_compile_definitions(ztd.idk.benchmarks.bit.opaque
5151
PUBLIC
5252
ZTD_OPAQUE_DLL=1
5353
)
54-
target_compile_options(ztd.idk.benchmarks.opaque PRIVATE
54+
target_compile_options(ztd.idk.benchmarks.bit.opaque PRIVATE
5555
${--utf8-literal-encoding}
5656
${--utf8-source-encoding}
5757
${--disable-permissive}

‎benchmarks/closures/CMakeLists.txt‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# =============================================================================
2+
#
3+
# ztd.idk
4+
# Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
5+
# Contact: opensource@soasis.org
6+
#
7+
# Commercial License Usage
8+
# Licensees holding valid commercial ztd.idk licenses may use this file in
9+
# accordance with the commercial license agreement provided with the
10+
# Software or, alternatively, in accordance with the terms contained in
11+
# a written agreement between you and Shepherd's Oasis, LLC.
12+
# For licensing terms and conditions see your agreement. For
13+
# further information contact opensource@soasis.org.
14+
#
15+
# Apache License Version 2 Usage
16+
# Alternatively, this file may be used under the terms of Apache License
17+
# Version 2.0 (the "License") for non-commercial use; you may not use this
18+
# file except in compliance with the License. You may obtain a copy of the
19+
# License at
20+
#
21+
# https://www.apache.org/licenses/LICENSE-2.0
22+
#
23+
# Unless required by applicable law or agreed to in writing, software
24+
# distributed under the License is distributed on an "AS IS" BASIS,
25+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26+
# See the License for the specific language governing permissions and
27+
# limitations under the License.
28+
#
29+
# ============================================================================>
30+
31+
# # Dependencies
32+
# k_value library
33+
add_subdirectory(k_value)
34+
# nontype_functional
35+
FetchContent_Declare(
36+
nontype_functional
37+
GIT_REPOSITORY https://github.com/zhihaoy/nontype_functional.git
38+
GIT_TAG main
39+
EXCLUDE_FROM_ALL
40+
)
41+
FetchContent_MakeAvailable(nontype_functional)
42+
43+
# # Benchmark Executable
44+
file(GLOB_RECURSE ztd.idk.benchmarks.closures.sources CONFIGURE_DEPENDS source/**)
45+
46+
# # Needed flags
47+
check_compiler_flag(use-blocks GCC -fblocks Clang -fblocks)
48+
check_compiler_diagnostic(c99-extensions)
49+
50+
add_executable(ztd.idk.benchmarks.closures ${ztd.idk.benchmarks.closures.sources})
51+
target_include_directories(ztd.idk.benchmarks.closures PRIVATE
52+
include
53+
source/include
54+
)
55+
target_link_libraries(ztd.idk.benchmarks.closures PRIVATE
56+
ztd::idk
57+
ztd::idk::benchmarks::closures::k_value
58+
std23::nontype_functional
59+
benchmark
60+
${CMAKE_DL_LIBS}
61+
)
62+
target_compile_options(ztd.idk.benchmarks.closures
63+
PRIVATE
64+
${--utf8-literal-encoding}
65+
${--utf8-source-encoding}
66+
${--use-blocks}
67+
${--allow-microsoft-enum-value}
68+
${--allow-c99-extensions}
69+
)
70+
set_target_properties(ztd.idk.benchmarks.closures
71+
PROPERTIES
72+
CXX_EXTENSIONS TRUE
73+
)
74+
75+
ztd_tools_add_benchmark_grapher(
76+
NAME
77+
closures
78+
CONFIG
79+
"${CMAKE_CURRENT_SOURCE_DIR}/graph_config.json"
80+
TARGETS
81+
ztd.idk.benchmarks.closures
82+
REPETITIONS
83+
${ZTD_IDK_BENCHMARKS_REPETITIONS}
84+
)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "closure test",
3+
"scale": {
4+
"type": "relative",
5+
"to": "base"
6+
},
7+
"categories": [
8+
{
9+
"name": "Rosetta Code Example",
10+
"pattern": "*",
11+
"ascending": true,
12+
"description": "A benchmark for determining the runtime of a Wikibooks / Rosetta Code example under many different kinds of languages."
13+
}
14+
],
15+
"data_groups": [
16+
{
17+
"name": "Lambdas",
18+
"pattern": "lambda",
19+
"description": ""
20+
},
21+
{
22+
"name": "Lambdas",
23+
"pattern": "lambda",
24+
"description": ""
25+
},
26+
{
27+
"name": "Lambdas",
28+
"pattern": "lambda_function_ref",
29+
"description": ""
30+
},
31+
{
32+
"name": "Normal Functions (Manual Struct Capture, Modified Argument)",
33+
"pattern": "normal_functions_rosetta",
34+
"description": "The use of plain C functions in the Man or Boy tests. Modifies the function arguments list to transfer data."
35+
},
36+
{
37+
"name": "Normal Functions (Statics)",
38+
"pattern": "normal_function_statics",
39+
"description": "The use of plain C functions with statics for data transfer in the Man or Boy tests."
40+
},
41+
{
42+
"name": "GNU Nested Functions",
43+
"pattern": "gnu_nested_functions",
44+
"description": "The use of the GNU Nested Functions C extension for the Man or Boy tests."
45+
},
46+
{
47+
"name": "Apple Blocks",
48+
"pattern": "apple_blocks",
49+
"description": "The use of the Apple Blocks extension for the Man or Boy tests."
50+
}
51+
],
52+
"data_labels": [
53+
{
54+
"name": "real time",
55+
"id": "real_time",
56+
"format": "clock",
57+
"primary": true
58+
},
59+
{
60+
"name": "cpu time",
61+
"id": "cpu_time",
62+
"format": "clock"
63+
}
64+
],
65+
"remove_suffixes": [
66+
",",
67+
"_"
68+
],
69+
"remove_prefixes": [
70+
",",
71+
"_"
72+
]
73+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# =============================================================================
2+
#
3+
# ztd.idk
4+
# Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
5+
# Contact: opensource@soasis.org
6+
#
7+
# Commercial License Usage
8+
# Licensees holding valid commercial ztd.idk licenses may use this file in
9+
# accordance with the commercial license agreement provided with the
10+
# Software or, alternatively, in accordance with the terms contained in
11+
# a written agreement between you and Shepherd's Oasis, LLC.
12+
# For licensing terms and conditions see your agreement. For
13+
# further information contact opensource@soasis.org.
14+
#
15+
# Apache License Version 2 Usage
16+
# Alternatively, this file may be used under the terms of Apache License
17+
# Version 2.0 (the "License") for non-commercial use; you may not use this
18+
# file except in compliance with the License. You may obtain a copy of the
19+
# License at
20+
#
21+
# https://www.apache.org/licenses/LICENSE-2.0
22+
#
23+
# Unless required by applicable law or agreed to in writing, software
24+
# distributed under the License is distributed on an "AS IS" BASIS,
25+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26+
# See the License for the specific language governing permissions and
27+
# limitations under the License.
28+
#
29+
# ============================================================================>
30+
31+
# # K_value Library
32+
file(GLOB_RECURSE ztd.idk.benchmarks.closures.k_value.sources
33+
CONFIGURE_DEPENDS
34+
source/**.cpp source/**.c)
35+
36+
add_library(ztd.idk.benchmarks.closures.k_value SHARED ${ztd.idk.benchmarks.closures.k_value.sources})
37+
add_library(ztd::idk::benchmarks::closures::k_value ALIAS ztd.idk.benchmarks.closures.k_value)
38+
target_include_directories(ztd.idk.benchmarks.closures.k_value
39+
PUBLIC
40+
include/
41+
)
42+
target_link_libraries(ztd.idk.benchmarks.closures.k_value PRIVATE
43+
ztd::idk
44+
${CMAKE_DL_LIBS}
45+
)
46+
target_compile_definitions(ztd.idk.benchmarks.closures.k_value
47+
PRIVATE
48+
ZTD_K_VALUE_BUILD=1
49+
)
50+
target_compile_definitions(ztd.idk.benchmarks.closures.k_value
51+
PUBLIC
52+
ZTD_K_VALUE_DLL=1
53+
)
54+
target_compile_options(ztd.idk.benchmarks.closures.k_value PRIVATE
55+
${--utf8-literal-encoding}
56+
${--utf8-source-encoding}
57+
${--disable-permissive}
58+
${--warn-pedantic}
59+
${--warn-default}
60+
${--warn-extra}
61+
${--warn-errors}
62+
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// =============================================================================
2+
//
3+
// ztd.idk
4+
// Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
5+
// Contact: opensource@soasis.org
6+
//
7+
// Commercial License Usage
8+
// Licensees holding valid commercial ztd.idk licenses may use this file in
9+
// accordance with the commercial license agreement provided with the
10+
// Software or, alternatively, in accordance with the terms contained in
11+
// a written agreement between you and Shepherd's Oasis, LLC.
12+
// For licensing terms and conditions see your agreement. For
13+
// further information contact opensource@soasis.org.
14+
//
15+
// Apache License Version 2 Usage
16+
// Alternatively, this file may be used under the terms of Apache License
17+
// Version 2.0 (the "License") for non-commercial use; you may not use this
18+
// file except in compliance with the License. You may obtain a copy of the
19+
// License at
20+
//
21+
// https://www.apache.org/licenses/LICENSE-2.0
22+
//
23+
// Unless required by applicable law or agreed to in writing, software
24+
// distributed under the License is distributed on an "AS IS" BASIS,
25+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26+
// See the License for the specific language governing permissions and
27+
// limitations under the License.
28+
//
29+
// ============================================================================ //
30+
31+
#include <k_value/version.h>
32+
33+
#include <stddef.h>
34+
35+
ZTD_USE(ZTD_EXTERN_C) ZTD_USE(ZTD_K_VALUE_API_LINKAGE) int k_value();
36+
37+
ZTD_USE(ZTD_EXTERN_C) ZTD_USE(ZTD_K_VALUE_API_LINKAGE) int expected_k_value();

0 commit comments

Comments
 (0)