Skip to content
Merged
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
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ if("${BUILD_TESTING}")
cxx_acceptance_test_dir
"${cxx_test_dir}/acceptance_tests/${PROJECT_NAME}"
)
set(
cxx_performance_test_dir
"${cxx_test_dir}/performance_tests/${PROJECT_NAME}"
)
set(python_test_dir "${CMAKE_CURRENT_LIST_DIR}/tests/python")
set(python_unit_test_dir "${python_test_dir}/unit_tests")

Expand All @@ -100,6 +104,13 @@ if("${BUILD_TESTING}")
DEPENDS Catch2 ${PROJECT_NAME}
)

cmaize_add_tests(
test_performance_${PROJECT_NAME}
SOURCE_DIR "${cxx_performance_test_dir}"
INCLUDE_DIRS "${project_src_dir}"
DEPENDS Catch2 ${PROJECT_NAME}
)

cmaize_add_tests(
acceptance_test_${PROJECT_NAME}
SOURCE_DIR "${cxx_acceptance_test_dir}"
Expand Down
37 changes: 37 additions & 0 deletions tests/cxx/performance_tests/tensorwrapper/contraction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2025 NWChemEx-Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "performance_testing.hpp"
#include <iostream>
#include <parallelzone/parallelzone.hpp>

using namespace tensorwrapper;

TEST_CASE("Contraction") {
Tensor A{1.0, 2.0, 3.0};
Tensor B{4.0, 5.0, 6.0};
Tensor C;

auto l = [&A, &B, &C]() {
C("") = A("i") * B("i");
return C;
};

parallelzone::hardware::CPU cpu;
auto [rv, info] = cpu.profile_it(std::move(l));

std::cout << "Time in ns: " << info.wall_time.count() << std::endl;
}
22 changes: 22 additions & 0 deletions tests/cxx/performance_tests/tensorwrapper/performance_testing.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2025 NWChemEx-Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#include <catch2/catch_approx.hpp>
#include <catch2/catch_template_test_macros.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <tensorwrapper/tensorwrapper.hpp>
27 changes: 27 additions & 0 deletions tests/cxx/performance_tests/tensorwrapper/test_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2024 NWChemEx Community
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#define CATCH_CONFIG_RUNNER
#include <catch2/catch_session.hpp>
#include <parallelzone/runtime/runtime_view.hpp>

int main(int argc, char* argv[]) {
auto rt = parallelzone::runtime::RuntimeView(argc, argv);

int res = Catch::Session().run(argc, argv);

return res;
}