1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 15:39:07 +00:00

kyber matrix generation bench

This commit is contained in:
Henry Case 2021-04-22 22:34:07 +01:00
parent 56629c53f9
commit 6e0b153ed3

View File

@ -6,6 +6,11 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include <benchmark/../../src/statistics.h> #include <benchmark/../../src/statistics.h>
#include <benchmark/../../src/cycleclock.h> #include <benchmark/../../src/cycleclock.h>
#include "kem/kyber/kyber512/avx2/polyvec.h"
extern "C" {
#include "kem/kyber/kyber512/avx2/indcpa.h"
}
auto cpucycle = [](benchmark::State &st, int64_t cycles) { auto cpucycle = [](benchmark::State &st, int64_t cycles) {
st.counters["CPU cycles: mean"] = benchmark::Counter( st.counters["CPU cycles: mean"] = benchmark::Counter(
@ -14,9 +19,13 @@ auto cpucycle = [](benchmark::State &st, int64_t cycles) {
static void BenchKyberMatK2(benchmark::State &st) { static void BenchKyberMatK2(benchmark::State &st) {
int64_t t, total = 0; int64_t t, total = 0;
polyvec a[KYBER_K];
uint8_t seed[32];
for (auto _ : st) { for (auto _ : st) {
t = benchmark::cycleclock::Now(); t = benchmark::cycleclock::Now();
PQCLEAN_KYBER512_AVX2_gen_matrix(a, seed, 0);
total += benchmark::cycleclock::Now() - t; total += benchmark::cycleclock::Now() - t;
benchmark::DoNotOptimize(a);
} }
cpucycle(st, total); cpucycle(st, total);
} }