Skip to content

Commit

Permalink
Add some cpp<->chai performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lefticus committed Feb 5, 2016
1 parent 08ba646 commit e082763
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Expand Up @@ -397,6 +397,14 @@ if(BUILD_TESTING)
add_test(NAME performance.${filename} COMMAND ${VALGRIND} --tool=callgrind --callgrind-out-file=callgrind.performance.${filename} $<TARGET_FILE:chai> ${CMAKE_CURRENT_SOURCE_DIR}/performance_tests/${filename})
list(APPEND TESTS performance.${filename})
endforeach()

add_executable(profile_cpp_calls_2 performance_tests/profile_cpp_calls_2.cpp)
target_link_libraries(profile_cpp_calls_2 ${LIBS})
add_test(NAME performance.profile_cpp_calls_2 COMMAND ${VALGRIND} --tool=callgrind --callgrind-out-file=callgrind.performance.profile_cpp_calls_2 $<TARGET_FILE:profile_cpp_calls_2>)

add_executable(profile_fun_wrappers performance_tests/profile_fun_wrappers.cpp)
target_link_libraries(profile_fun_wrappers ${LIBS})
add_test(NAME performance.profile_fun_wrappers COMMAND ${VALGRIND} --tool=callgrind --callgrind-out-file=callgrind.performance.profile_fun_wrappers $<TARGET_FILE:profile_fun_wrappers>)
endif()

set_property(TEST ${TESTS}
Expand Down
20 changes: 20 additions & 0 deletions performance_tests/profile_cpp_calls_2.cpp
@@ -0,0 +1,20 @@
#include <chaiscript/chaiscript.hpp>
#include <chaiscript/chaiscript_stdlib.hpp>

double f(const std::string &, double, bool) noexcept {
return .0;
}

int main()
{
chaiscript::ChaiScript chai(chaiscript::Std_Lib::library());

chai.add(chaiscript::fun(&f), "f");

chai.eval(R"(
for (var i = 0; i < 100000; ++i) {
f("str", 1.2, false);
}
)");

}
20 changes: 20 additions & 0 deletions performance_tests/profile_fun_wrappers.cpp
@@ -0,0 +1,20 @@
#include <chaiscript/chaiscript.hpp>
#include <chaiscript/chaiscript_stdlib.hpp>

double f(const std::string &, double, bool) noexcept {
return .0;
}

int main()
{
chaiscript::ChaiScript chai(chaiscript::Std_Lib::library());

chai.add(chaiscript::fun(&f), "f");

const auto f = chai.eval<std::function<void ()>>(R"(fun(){ f("str", 1.2, false); })");

for (int i = 0; i < 100000; ++i) {
f();
}

}

16 comments on commit e082763

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (397 of 397 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-Linux-Ubuntu-14.04-clang-3.5-LibC++: OK (389 of 389 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - i386-Windows-10-VisualStudio-14: OK (388 of 389 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - Win64-Windows-10-VisualStudio-14: OK (388 of 389 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-Linux-Ubuntu-14.04-clang-3.6-AddressSanitizer: OK (3047 of 3047 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - i386-Windows-10-VisualStudio-12: OK (388 of 389 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-Linux-Ubuntu-14.04-clang-3.6-ThreadSanitizer: OK (389 of 389 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - Win64-Windows-10-VisualStudio-12: OK (388 of 389 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-Linux-Ubuntu-14.04-gcc-4.8-NoThreads: OK (393 of 396 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-Linux-Ubuntu-14.04-gcc-4.8: OK (397 of 397 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-Linux-Ubuntu-14.04-gcc-4.6: OK (397 of 397 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed, 0 test warnings)

Build Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-Linux-Ubuntu-14.04-custom_check: OK (0 of 0 tests passed, 0 test warnings)

Build Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-MacOS-10.9-clang: OK (389 of 389 tests passed, 0 test warnings)

Build Badge Test Badge

@lefticus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-5.x (lefticus) - x86_64-MacOS-10.9-clang-Debug: OK (389 of 389 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.