Line data Source code
1 : // Copyright 2024 The LevelDB-Go and Pebble Authors. All rights reserved. Use 2 : // of this source code is governed by a BSD-style license that can be found in 3 : // the LICENSE file. 4 : 5 : package invariants 6 : 7 : import "github.com/cockroachdb/pebble/internal/fastrand" 8 : 9 : // Sometimes returns true percent% of the time if we were built with the 10 : // "invariants" of "race" build tags 11 2 : func Sometimes(percent int) bool { 12 2 : return Enabled && fastrand.Uint32()%100 < uint32(percent) 13 2 : }