Skip to content

Instantly share code, notes, and snippets.

@balloonio
Created November 12, 2018 20:38
Show Gist options
  • Save balloonio/e1da3c4b095fac6d4bdc9a93a12b2abe to your computer and use it in GitHub Desktop.
Save balloonio/e1da3c4b095fac6d4bdc9a93a12b2abe to your computer and use it in GitHub Desktop.
Weighted random cache testing code
wr = WeightRandom()
wr.setObjectWeight(1, 1)
wr.setObjectWeight(2, 1)
wr.setObjectWeight(2, 0)
wr.setObjectWeight(3, 2)
for i in range(10):
print(wr.getRandom())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment