MCPcopy Create free account
hub / github.com/Tencent/phxsql / CheckByRatio

Function CheckByRatio

phxsqlclient/utils/random.cpp:85–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85bool CheckByRatio(unsigned int base, unsigned int ratio) {
86 if (base == 0 || ratio == 0) {
87 return false;
88 } else if (ratio >= base) {
89 return true;
90 }
91
92 unsigned int n = GetFastRandom() % base;
93 return n < ratio;
94}
95
96unsigned int RandomPicker(unsigned int maxVal) {
97 return RandomPicker(0, maxVal);

Callers

nothing calls this directly

Calls 1

GetFastRandomFunction · 0.85

Tested by

no test coverage detected