Skip to content

Commit

Permalink
WIP add benchmark for impact of ureact root includes on compilation t…
Browse files Browse the repository at this point in the history
…imes
  • Loading branch information
YarikTH committed Aug 21, 2023
1 parent b9ac133 commit 7065d9c
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/compilation_time/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target_sources(
PRIVATE #
compiler_args.cpp
std_headers_include_time.cpp
ureact_headers_include_time.cpp
transform_compilation.cpp
)

Expand Down
25 changes: 25 additions & 0 deletions tests/compilation_time/test_samples/include_ureact.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Copyright (C) 2020-2023 Krylov Yaroslav.
//
// 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)
//
#if defined( INCLUDE_CONTEXT ) or defined( INCLUDE_ALL )
# include <ureact/context.hpp>
#endif

#if defined( INCLUDE_EVENTS ) or defined( INCLUDE_ALL )
# include <ureact/events.hpp>
#endif

#if defined( INCLUDE_OBSERVER ) or defined( INCLUDE_ALL )
# include <ureact/observer.hpp>
#endif

#if defined( INCLUDE_SIGNAL ) or defined( INCLUDE_ALL )
# include <ureact/signal.hpp>
#endif

int main()
{}
71 changes: 71 additions & 0 deletions tests/compilation_time/ureact_headers_include_time.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// Copyright (C) 2020-2023 Krylov Yaroslav.
//
// 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)
//
#include <algorithm>
#include <cassert>
#include <string>

#include <catch2/catch_test_macros.hpp>
#include <nanobench.h>

#include "compiler_args.hpp"

TEST_CASE( "ureact headers include time" )
{
using namespace std::chrono_literals;

ankerl::nanobench::Bench bench;
bench.title( "ureact headers include time" );
bench.relative( true );
bench.performanceCounters( false );
bench.timeUnit( 1ms, "ms" );
bench.minEpochIterations( 1 );

std::vector compilers = {
Compiler{ gcc, 9 },
Compiler{ gcc, 10 },
Compiler{ gcc, 11 },
Compiler{ gcc, 12 },
Compiler{ clang, 11 },
Compiler{ clang, 12 },
Compiler{ clang, 13 },
Compiler{ clang, 14 },
};

const auto args = generateCompilerArgs(
compilers, { BuildConfiguration::Debug, BuildConfiguration::Release }, 17 );
for( const auto& compilerArgs : args )
{
const auto compilerString = compilerArgs.get_name();

for( const std::string& type : {
"all",
"context",
"events",
"observer",
"signal",
} )
{
for( bool useStdAlgorithm : { false, true } )
{
auto stdCompilerArgs = CompilerArgs{ compilerArgs } //
.source( "include_ureact.cpp" );
std::string definition = "INCLUDE_" + type;
std::transform(
definition.begin(), definition.end(), definition.begin(), ::toupper );
stdCompilerArgs.definition( definition );
if( useStdAlgorithm )
stdCompilerArgs.definition( "UREACT_USE_STD_ALGORITHM" );

perform_test( bench,
type + " (" + compilerString + ") "
+ ( useStdAlgorithm ? "std algorithm" : "ureact algorithm" ),
stdCompilerArgs );
}
}
}
}

0 comments on commit 7065d9c

Please sign in to comment.