forked from msaindon/deuces
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathplo_perf.py
62 lines (46 loc) · 1.42 KB
/
plo_perf.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
import time
from treys.deck import Deck
from treys.evaluator import PLOEvaluator
def setup(n: int, m: int) -> tuple[list[list[int]], list[list[int]]]:
deck = Deck()
boards = []
hands = []
for _ in range(n):
boards.append(deck.draw(m))
hands.append(deck.draw(4))
deck.shuffle()
return boards, hands
n = 10000
cumtime = 0.0
evaluator = PLOEvaluator()
boards, hands = setup(n, 5)
for i in range(len(boards)):
start = time.time()
evaluator.evaluate(hands[i], boards[i])
cumtime += (time.time() - start)
avg = float(cumtime / n)
print("9 card evaluation:")
print("[*] Treys: Average time per evaluation: %f" % avg)
print("[*] Treys: Evaluations per second = %f" % (1.0 / avg))
###
cumtime = 0.0
boards, hands = setup(n, 4)
for i in range(len(boards)):
start = time.time()
evaluator.evaluate(hands[i], boards[i])
cumtime += (time.time() - start)
avg = float(cumtime / n)
print("8 card evaluation:")
print("[*] Treys: Average time per evaluation: %f" % avg)
print("[*] Treys: Evaluations per second = %f" % (1.0 / avg))
###
cumtime = 0.0
boards, hands = setup(n, 3)
for i in range(len(boards)):
start = time.time()
evaluator.evaluate(hands[i], boards[i])
cumtime += (time.time() - start)
avg = float(cumtime / n)
print("7 card evaluation:")
print("[*] Treys: Average time per evaluation: %f" % avg)
print("[*] Treys: Evaluations per second = %f" % (1.0 / avg))