Skip to content

Commit

Permalink
WIP add <ureact/context.hpp> compilation time benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikTH committed Aug 24, 2023
1 parent 3feb38c commit ebdfb1f
Show file tree
Hide file tree
Showing 3 changed files with 91 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 @@ -13,6 +13,7 @@ target_sources(
compiler_args.cpp
std_headers_include_time.cpp
ureact_headers_include_time.cpp
context.cpp
signal.cpp
events.cpp
transform_compilation.cpp
Expand Down
70 changes: 70 additions & 0 deletions tests/compilation_time/context.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// 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 <catch2/catch_test_macros.hpp>
#include <nanobench.h>

#include "compiler_args.hpp"

TEST_CASE( "context compilation time" )
{
using namespace std::chrono_literals;

ankerl::nanobench::Bench bench;
bench.title( "context compilation 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();

{
perform_test( bench,
std::string{ "std include" } + " (" + compilerString + ')',
CompilerArgs{ compilerArgs } //
.source( "include_std.cpp" )
.definition( "INCLUDE_ALL" )
//
);
}

{
perform_test( bench,
std::string{ "include" } + " (" + compilerString + ')',
CompilerArgs{ compilerArgs } //
.source( "context.cpp" )
.definition( "INCLUDE_ONLY" )
//
);
}

{
perform_test( bench,
std::string{ "context" } + " (" + compilerString + ')',
CompilerArgs{ compilerArgs } //
.source( "context.cpp" )
//
);
}
}
}
20 changes: 20 additions & 0 deletions tests/compilation_time/test_samples/context.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// 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 <ureact/context.hpp>

#ifndef INCLUDE_ONLY

void test()
{
ureact::context ctx;
}

#endif

int main()
{}

0 comments on commit ebdfb1f

Please sign in to comment.