Skip to content
Merged
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
8 changes: 8 additions & 0 deletions test/internal_benchmarks/modarith_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace
constexpr auto bn254 = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47_u256;
constexpr auto secp256k1 = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f_u256;

// Each pair of operations forms a single dependency chain, so the reported time is the latency.

template <typename UintT, const UintT& Mod>
void modarith_add(benchmark::State& state)
{
Expand All @@ -24,6 +26,8 @@ void modarith_add(benchmark::State& state)
a = m.add(a, b);
b = m.add(b, a);
}
benchmark::DoNotOptimize(a);
benchmark::DoNotOptimize(b);
}

template <typename UintT, const UintT& Mod>
Expand All @@ -38,6 +42,8 @@ void modarith_sub(benchmark::State& state)
a = m.sub(a, b);
b = m.sub(b, a);
}
benchmark::DoNotOptimize(a);
benchmark::DoNotOptimize(b);
}

template <typename UintT, const UintT& Mod>
Expand All @@ -52,6 +58,8 @@ void modarith_mul(benchmark::State& state)
a = m.mul(a, b);
b = m.mul(b, a);
}
benchmark::DoNotOptimize(a);
benchmark::DoNotOptimize(b);
}
} // namespace

Expand Down