From c456490f7364af9598c4a8ae6e81e3930ed53d4c Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Thu, 24 Sep 2020 13:48:39 +0900 Subject: [PATCH] bench of inv --- test/bench.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/bench.hpp b/test/bench.hpp index f7acfce..09af59e 100644 --- a/test/bench.hpp +++ b/test/bench.hpp @@ -52,6 +52,12 @@ void benchAddDblG2() CYBOZU_BENCH_C("G2::dbl(2)", C, G2::dbl, P3, P1); } +template +void invAdd(T& out, const T& x, const T& y) +{ + T::inv(out, x); + out += y; +} void testBench(const G1& P, const G2& Q) { @@ -99,7 +105,7 @@ void testBench(const G1& P, const G2& Q) CYBOZU_BENCH_C("Fp::neg ", C3, Fp::neg, x, x); CYBOZU_BENCH_C("Fp::mul ", C3, Fp::mul, x, x, y); CYBOZU_BENCH_C("Fp::sqr ", C3, Fp::sqr, x, x); - CYBOZU_BENCH_C("Fp::inv ", C3, Fp::inv, x, x); + CYBOZU_BENCH_C("Fp::inv ", C3, invAdd, x, x, y); CYBOZU_BENCH_C("Fp::pow ", C3, Fp::pow, x, x, y); { Fr a, b, c; @@ -110,7 +116,7 @@ void testBench(const G1& P, const G2& Q) CYBOZU_BENCH_C("Fr::neg ", C3, Fr::neg, a, a); CYBOZU_BENCH_C("Fr::mul ", C3, Fr::mul, a, a, b); CYBOZU_BENCH_C("Fr::sqr ", C3, Fr::sqr, a, a); - CYBOZU_BENCH_C("Fr::inv ", C3, Fr::inv, a, a); + CYBOZU_BENCH_C("Fr::inv ", C3, invAdd, a, a, b); CYBOZU_BENCH_C("Fr::pow ", C3, Fr::pow, a, a, b); } Fp2 xx, yy; @@ -128,7 +134,7 @@ void testBench(const G1& P, const G2& Q) CYBOZU_BENCH_C("Fp2::mul ", C3, Fp2::mul, xx, xx, yy); CYBOZU_BENCH_C("Fp2::mul_xi ", C3, Fp2::mul_xi, xx, xx); CYBOZU_BENCH_C("Fp2::sqr ", C3, Fp2::sqr, xx, xx); - CYBOZU_BENCH_C("Fp2::inv ", C3, Fp2::inv, xx, xx); + CYBOZU_BENCH_C("Fp2::inv ", C3, invAdd, xx, xx, yy); CYBOZU_BENCH_C("FpDbl::addPre ", C3, FpDbl::addPre, d1, d1, d0); CYBOZU_BENCH_C("FpDbl::subPre ", C3, FpDbl::subPre, d1, d1, d0); CYBOZU_BENCH_C("FpDbl::add ", C3, FpDbl::add, d1, d1, d0);