Created
September 25, 2022 22:56
-
-
Save amirziai/f9c9025b554604b29333f574ff89ad06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def experiment_capacity(a_tokens: int) -> float: | |
assert a_tokens >= 2 and a_tokens % 2 == 0 | |
a = random_str() | |
b = random_str() | |
ch = ConsistentHashingWithTokens( | |
server_tokens={a: a_tokens, b: a_tokens // 2}, | |
) | |
return sum( | |
ch.key_lookup(key=url) == a | |
for url in urls | |
) / len(urls) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment