diff --git a/gmeasure/experiment.go b/gmeasure/experiment.go index 2ac521d73..bc8fb7931 100644 --- a/gmeasure/experiment.go +++ b/gmeasure/experiment.go @@ -40,6 +40,7 @@ package gmeasure import ( "fmt" "math" + "math/big" "reflect" "sync" "time" @@ -452,9 +453,11 @@ func (e *Experiment) Sample(callback func(idx int), samplingConfig SamplingConfi if samplingConfig.Duration > 0 { maxTime = time.Now().Add(samplingConfig.Duration) } - maxN := math.MaxInt64 + maxN := big.NewInt(math.MaxInt64) if samplingConfig.N > 0 { - maxN = samplingConfig.N + // NOTE(aznashwan): we print then parse the samplingConfig.N to future-proof + // against variations in the bit size of the standard int type: + maxN.SetString(fmt.Sprintf("%d", samplingConfig.N), 10) } numParallel := 1 if samplingConfig.NumParallel > numParallel { @@ -491,7 +494,12 @@ func (e *Experiment) Sample(callback func(idx int), samplingConfig SamplingConfi avgDt = (avgDt*time.Duration(idx-numParallel) + dt) / time.Duration(idx-numParallel+1) } idx += 1 - if idx >= maxN { + + idxBigInt := big.NewInt(0) + // NOTE(aznashwan): we print then parse the integer idx to future-proof + // against variations in the bit size of the standard int type: + idxBigInt.SetString(fmt.Sprintf("%d", idx), 10) + if idxBigInt.Cmp(maxN) >= 0 { return } if time.Now().Add(avgDt).After(maxTime) {