test: add benchmark

This commit is contained in:
parker
2025-07-10 19:25:06 +01:00
parent 433c66cd5a
commit 72de0c5602
3 changed files with 61 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ set(CMAKE_CXX_STANDARD 17)
# set exec names
set(AppExec enzoGui)
set(TestExec tests)
set(BenchExec bench)
set(CMAKE_AUTORCC ON)
# setup project
@@ -81,3 +82,19 @@ add_executable(${TestExec}
target_link_libraries(${TestExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core )
target_compile_definitions(${TestExec} PRIVATE UNIT_TEST)
target_include_directories(${TestExec} PUBLIC src)
# benchmarks
add_executable(${BenchExec}
tests/Benchmarks.cpp
src/Engine/Operator/Attribute.cpp
src/Engine/Operator/Geometry.cpp
src/Engine/Operator/GeometryOperator.cpp
src/Engine/Network/NetworkManager.cpp
src/Engine/Operator/GeometryConnection.cpp
src/Engine/Operator/GeometryOpDef.cpp
)
target_link_libraries(${BenchExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core )
target_compile_definitions(${BenchExec} PRIVATE UNIT_TEST)
target_include_directories(${BenchExec} PUBLIC src)

43
tests/Benchmarks.cpp Normal file
View File

@@ -0,0 +1,43 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/benchmark/catch_benchmark.hpp>
#include <memory>
#include "Engine/Network/NetworkManager.h"
#include "Engine/Operator/GeometryOperator.h"
#include "Engine/Types.h"
#include <iostream>
struct NMReset
{
NMReset()
{
enzo::nt::NetworkManager::_reset();
}
~NMReset()
{
enzo::nt::NetworkManager::_reset();
}
};
TEST_CASE_METHOD(NMReset, "Network Manager")
{
using namespace enzo;
nt::OpId prevOp = 0;
for(int i=0; i<100; ++i){
nt::OpId newOp = nt::NetworkManager::addOperator();
if(prevOp!=0)
{
nt::connectOperators(newOp, 0, prevOp, 0);
}
prevOp = newOp;
}
nt::NetworkManager* nm = nt::NetworkManager::getInstance();
BENCHMARK("Cook 100 Ops")
{
nm->setDisplayOp(prevOp);
};
}

View File

@@ -1,4 +1,5 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/benchmark/catch_benchmark.hpp>
#include <memory>
#include "Engine/Network/NetworkManager.h"
#include "Engine/Operator/GeometryOperator.h"