mirror of
https://github.com/henrydcase/pqc.git
synced 2024-12-04 13:24:04 +00:00
add benchmarking framework
This commit is contained in:
parent
59df9a3f73
commit
56629c53f9
14
.astylerc
14
.astylerc
@ -1,14 +0,0 @@
|
|||||||
--style=google
|
|
||||||
--indent=spaces
|
|
||||||
--indent-preproc-define
|
|
||||||
--indent-preproc-cond
|
|
||||||
--pad-oper
|
|
||||||
--pad-comma
|
|
||||||
--pad-header
|
|
||||||
#--unpad-paren
|
|
||||||
--align-pointer=name
|
|
||||||
--add-braces
|
|
||||||
--convert-tabs
|
|
||||||
--mode=c
|
|
||||||
# disable backup files
|
|
||||||
--suffix=none
|
|
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -1,6 +0,0 @@
|
|||||||
* text=auto
|
|
||||||
*.[ch] text whitespacestrict
|
|
||||||
*.yaml text whitespacestrict
|
|
||||||
Makefile text whitespace="tabwidth=4,-tab-in-indent,indent-with-non-tab"
|
|
||||||
|
|
||||||
[attr]whitespacestrict whitespace="trailing-space,tab-in-indent,space-before-tab,tabwidth=4"
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,6 +8,3 @@ bin/
|
|||||||
# Object and library files on Windows
|
# Object and library files on Windows
|
||||||
*.lib
|
*.lib
|
||||||
*.obj
|
*.obj
|
||||||
|
|
||||||
__pycache__
|
|
||||||
testcases/
|
|
||||||
|
@ -33,7 +33,21 @@ else()
|
|||||||
message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
|
message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(3rd/gtest)
|
add_subdirectory(${CMAKE_SOURCE_DIR}/3rd/gtest)
|
||||||
|
if(NOT CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
|
||||||
|
# settings below are required by benchmark library
|
||||||
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
|
||||||
|
# Target for benchmark - it also builds gtest library
|
||||||
|
set(BENCHMARK_ENABLE_GTEST_TESTS ON CACHE BOOL "Enable testing of the benchmark library." FORCE)
|
||||||
|
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark tests" FORCE)
|
||||||
|
set(GOOGLETEST_PATH "${CMAKE_SOURCE_DIR}/3rd/gtest" CACHE PATH "Path to the gtest sources" FORCE)
|
||||||
|
#if (NOT MACOSX)
|
||||||
|
# set(BENCHMARK_ENABLE_LTO ON CACHE BOOL "Enable link time optim" FORCE)
|
||||||
|
#endif()
|
||||||
|
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
|
||||||
|
add_subdirectory(${CMAKE_SOURCE_DIR}/3rd/gbench)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# Arch settings
|
# Arch settings
|
||||||
|
|
||||||
@ -268,6 +282,9 @@ target_include_directories(
|
|||||||
|
|
||||||
${CMAKE_SOURCE_DIR})
|
${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
|
||||||
|
add_subdirectory(test/bench)
|
||||||
|
endif()
|
||||||
|
|
||||||
install(TARGETS pqc pqc_s
|
install(TARGETS pqc pqc_s
|
||||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE
|
||||||
|
15
test/bench/CMakeLists.txt
Normal file
15
test/bench/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
add_executable(
|
||||||
|
bench
|
||||||
|
kyber.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
bench
|
||||||
|
|
||||||
|
pqc
|
||||||
|
benchmark
|
||||||
|
benchmark_main
|
||||||
|
)
|
||||||
|
|
24
test/bench/kyber.cc
Normal file
24
test/bench/kyber.cc
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include <array>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
|
#include <benchmark/../../src/statistics.h>
|
||||||
|
#include <benchmark/../../src/cycleclock.h>
|
||||||
|
|
||||||
|
auto cpucycle = [](benchmark::State &st, int64_t cycles) {
|
||||||
|
st.counters["CPU cycles: mean"] = benchmark::Counter(
|
||||||
|
cycles, benchmark::Counter::kAvgIterations | benchmark::Counter::kResultNoFormat);
|
||||||
|
};
|
||||||
|
|
||||||
|
static void BenchKyberMatK2(benchmark::State &st) {
|
||||||
|
int64_t t, total = 0;
|
||||||
|
for (auto _ : st) {
|
||||||
|
t = benchmark::cycleclock::Now();
|
||||||
|
total += benchmark::cycleclock::Now() - t;
|
||||||
|
}
|
||||||
|
cpucycle(st, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK(BenchKyberMatK2);
|
Loading…
Reference in New Issue
Block a user