-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathbenchmark.py
More file actions
49 lines (36 loc) · 1.47 KB
/
benchmark.py
File metadata and controls
49 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import time
from itertools import combinations
from phevaluator import _evaluate_cards
from phevaluator import _evaluate_omaha_cards
from phevaluator import sample_cards
def evaluate_all_five_card_hands() -> None:
for cards in combinations(range(52), 5):
_evaluate_cards(*cards)
def evaluate_all_six_card_hands() -> None:
for cards in combinations(range(52), 6):
_evaluate_cards(*cards)
def evaluate_all_seven_card_hands() -> None:
for cards in combinations(range(52), 7):
_evaluate_cards(*cards)
def evaluate_random_omaha_card_hands() -> None:
total = 100_000
for _ in range(total):
cards = sample_cards(9)
_evaluate_omaha_cards(cards[:5], cards[5:])
def benchmark() -> None:
print("--------------------------------------------------------------------")
print("Benchmark Time")
t = time.process_time()
evaluate_random_omaha_card_hands()
print("evaluate_random_omaha_card_hands ", time.process_time() - t)
t = time.process_time()
evaluate_all_five_card_hands()
print("evaluate_all_five_card_hands ", time.process_time() - t)
t = time.process_time()
evaluate_all_six_card_hands()
print("evaluate_all_six_card_hands ", time.process_time() - t)
t = time.process_time()
evaluate_all_seven_card_hands()
print("evaluate_all_seven_card_hands ", time.process_time() - t)
if __name__ == "__main__":
benchmark()