Add console logs for benchmark data preparation

This commit is contained in:
Marek Lemańczyk committed 2025-10-18 14:44:14 +02:00
1 parent 44f65b1c8f
commit d1f3de07d7
3 files changed
+23 -3

No files matched your search

@@ -1,3 +1,4 @@
using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Jobs;
@@ -51,6 +52,8 @@ public class GpuModularArithmeticBenchmarks
private static ModularArithmeticSampleData Create() private static ModularArithmeticSampleData Create()
{ {
Console.WriteLine("Preparing modular arithmetic benchmark sample data...");
Random random = new(7); Random random = new(7);
var exponents = new ulong[MaxBatchSize]; var exponents = new ulong[MaxBatchSize];
var moduli = new ulong[MaxBatchSize]; var moduli = new ulong[MaxBatchSize];
@@ -66,7 +69,11 @@ public class GpuModularArithmeticBenchmarks
mersenneModuli[i] = (1UL << bits) - 1UL; mersenneModuli[i] = (1UL << bits) - 1UL;
} }
return new ModularArithmeticSampleData(exponents, moduli, mersenneModuli, mersenneBitWidths); ModularArithmeticSampleData data = new ModularArithmeticSampleData(exponents, moduli, mersenneModuli, mersenneBitWidths);
Console.WriteLine("Finished preparing modular arithmetic benchmark sample data.");
return data;
} }
private static ulong NextExponent(Random random) private static ulong NextExponent(Random random)
@@ -1,3 +1,4 @@
using System;
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Jobs;
@@ -51,6 +52,8 @@ public class MontgomeryMultiplyBenchmarks
private static MontgomerySampleData Create() private static MontgomerySampleData Create()
{ {
Console.WriteLine("Preparing Montgomery multiply benchmark sample data...");
Random random = new(1979); Random random = new(1979);
var operandsA = new ulong[MaxBatchSize]; var operandsA = new ulong[MaxBatchSize];
var operandsB = new ulong[MaxBatchSize]; var operandsB = new ulong[MaxBatchSize];
@@ -66,7 +69,11 @@ public class MontgomeryMultiplyBenchmarks
operandsB[i] = (ulong)random.NextInt64(0, (long)modulus); operandsB[i] = (ulong)random.NextInt64(0, (long)modulus);
} }
return new MontgomerySampleData(operandsA, operandsB, moduli, nPrimes); MontgomerySampleData data = new MontgomerySampleData(operandsA, operandsB, moduli, nPrimes);
Console.WriteLine("Finished preparing Montgomery multiply benchmark sample data.");
return data;
} }
private static ulong NextOddModulus(Random random) private static ulong NextOddModulus(Random random)
@@ -443,6 +443,8 @@ public class Pow2ModBenchmarks
private static SampleCollections Create() private static SampleCollections Create()
{ {
Console.WriteLine("Preparing power-of-two modulus benchmark sample collections...");
Random random = new(13); Random random = new(13);
Random heuristicRandom = new(113); Random heuristicRandom = new(113);
Random wideRandom = new(19); Random wideRandom = new(19);
@@ -486,7 +488,7 @@ public class Pow2ModBenchmarks
wideCycles[i] = CalculateCycleLengthWithHeuristics(wideModulus, ref previousWidePrimeOrder); wideCycles[i] = CalculateCycleLengthWithHeuristics(wideModulus, ref previousWidePrimeOrder);
} }
return new SampleCollections( SampleCollections collections = new SampleCollections(
smallDivisors, smallDivisors,
largeDivisors, largeDivisors,
veryLargeDivisors, veryLargeDivisors,
@@ -499,6 +501,10 @@ public class Pow2ModBenchmarks
largeCycles, largeCycles,
veryLargeCycles, veryLargeCycles,
wideCycles); wideCycles);
Console.WriteLine("Finished preparing power-of-two modulus benchmark sample collections.");
return collections;
} }
private static ulong NextSmallExponent(Random random) => (ulong)random.NextInt64(1L, 1_000_000L); private static ulong NextSmallExponent(Random random) => (ulong)random.NextInt64(1L, 1_000_000L);