diff --git a/bench/permutations.go b/bench/permutations.go index 9c1ba8b6a..cbe4162e4 100644 --- a/bench/permutations.go +++ b/bench/permutations.go @@ -48,9 +48,9 @@ func LCGmultiplierFromModulus(m int64, seed int64) int64 { return product*seed + 1 } +// Returns map of {integerFactor: count, ...} +// This is a naive algorithm that will not work well for large prime n. func primeFactors(n int64) map[int64]int { - // Returns map of {integerFactor: count, ...} - // This is a naive algorithm that will not work well for large prime n. factors := make(map[int64]int) for i := int64(2); i <= n; i++ { div, mod := n/i, n%i diff --git a/bench/zipf.go b/bench/zipf.go index 23eac3a1c..b3f443706 100644 --- a/bench/zipf.go +++ b/bench/zipf.go @@ -109,15 +109,14 @@ func (b *ZipfSetBits) ConsumeFlags(args []string) ([]string, error) { return fs.Args(), nil } +// Offset is the true parameter used by the Zipf distribution, but the ratio, +// as defined here, is a simpler, readable way to define the distribution. +// Offset is in [1, inf), and its meaning depends on N (a pain for updating benchmark configs) +// ratio is in (0, 1), and its meaning does not depend on N. +// it is the ratio of the lowest probability in the distribution to the highest. +// ratio=0.01 corresponds to a very small offset - the most skewed distribution for a given pair (N, exp) +// ratio=0.99 corresponds to a very large offset - the most nearly uniform distribution for a given (N, exp) func getZipfOffset(N int64, exp, ratio float64) float64 { - // Offset is the true parameter used by the Zipf distribution, but the ratio, - // as defined here, is a simpler, readable way to define the distribution. - // Offset is in [1, inf), and its meaning depends on N (a pain for updating benchmark configs) - // ratio is in (0, 1), and its meaning does not depend on N. - // it is the ratio of the lowest probability in the distribution to the highest. - // ratio=0.01 corresponds to a very small offset - the most skewed distribution for a given pair (N, exp) - // ratio=0.99 corresponds to a very large offset - the most nearly uniform distribution for a given (N, exp) - z := math.Pow(ratio, 1/exp) return z * float64(N-1) / (1 - z) }