Skip to content
Merged

Bench #102

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions bench/asio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@
# Official repository: https://github.com/cppalliance/corosio
#

# Asio benchmark executables for comparison
# Asio benchmark executable for comparison

function(asio_add_benchmark name source)
add_executable(${name} ${source})
target_link_libraries(${name}
PRIVATE
Boost::asio
Threads::Threads)
target_compile_features(${name} PUBLIC cxx_std_20)
target_compile_options(${name}
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-fcoroutines>)
set_property(TARGET ${name} PROPERTY FOLDER "benchmarks/asio")
if (COROSIO_BENCH_LTO_SUPPORTED)
set_property(TARGET ${name} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()
endfunction()
add_executable(asio_bench
main.cpp
io_context_bench.cpp
socket_throughput_bench.cpp
socket_latency_bench.cpp
http_server_bench.cpp)

asio_add_benchmark(asio_bench_io_context io_context_bench.cpp)
asio_add_benchmark(asio_bench_socket_throughput socket_throughput_bench.cpp)
asio_add_benchmark(asio_bench_socket_latency socket_latency_bench.cpp)
asio_add_benchmark(asio_bench_http_server http_server_bench.cpp)
target_link_libraries(asio_bench
PRIVATE
Boost::asio
Threads::Threads)

target_compile_features(asio_bench PUBLIC cxx_std_20)

target_compile_options(asio_bench
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-fcoroutines>)

set_property(TARGET asio_bench PROPERTY FOLDER "benchmarks/asio")

if (COROSIO_BENCH_LTO_SUPPORTED)
set_property(TARGET asio_bench PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif ()
59 changes: 59 additions & 0 deletions bench/asio/benchmarks.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Copyright (c) 2026 Steve Gerbino
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/corosio
//

#ifndef ASIO_BENCH_BENCHMARKS_HPP
#define ASIO_BENCH_BENCHMARKS_HPP

#include "../common/benchmark.hpp"

namespace asio_bench {

/** Run io_context benchmarks.

@param collector Results collector.
@param filter Optional filter: nullptr or "all" runs all, or a specific
benchmark name (single_threaded, multithreaded, interleaved, concurrent).
*/
void run_io_context_benchmarks(
bench::result_collector& collector,
char const* filter );

/** Run socket throughput benchmarks.

@param collector Results collector.
@param filter Optional filter: nullptr or "all" runs all, or a specific
benchmark name (unidirectional, bidirectional).
*/
void run_socket_throughput_benchmarks(
bench::result_collector& collector,
char const* filter );

/** Run socket latency benchmarks.

@param collector Results collector.
@param filter Optional filter: nullptr or "all" runs all, or a specific
benchmark name (pingpong, concurrent).
*/
void run_socket_latency_benchmarks(
bench::result_collector& collector,
char const* filter );

/** Run HTTP server benchmarks.

@param collector Results collector.
@param filter Optional filter: nullptr or "all" runs all, or a specific
benchmark name (single_conn, concurrent, multithread).
*/
void run_http_server_benchmarks(
bench::result_collector& collector,
char const* filter );

} // namespace asio_bench

#endif
Loading
Loading