-
Notifications
You must be signed in to change notification settings - Fork 1
/
_ordbBenchmark.py
36 lines (32 loc) · 977 Bytes
/
_ordbBenchmark.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
from tia.trad.market.orderbook import RecorderOrderbook, Order
import time
NTIME = 10**5
def timer(func):
def wrapper(*args):
stime = time.time()
func(*args)
etime = time.time()
print func.__name__, etime - stime
return wrapper
@timer
def sdPlaceOrderDiffPrice(orderbook):
for i in xrange(NTIME):
orderbook.asks[i] = Order(i, 10**8, 10**8)
#orderbook.bids[i] = Order(i, 10**8, 10**8)
@timer
def sdPlaceorderSamePrice(orderbook):
for i in xrange(NTIME):
orderbook.asks[1] = Order(1, 10**8, i)
@timer
def sdRemoveOrderSamePrice(orderbook):
for i in xrange(NTIME):
orderbook.asks[1] = Order(1, -10**8, i)
@timer
def sdRemoveOrderDiffPrice(orderbook):
for i in xrange(NTIME):
orderbook.asks[i] = Order(i, -10**8, i)
orderbook = RecorderOrderbook()
sdPlaceOrderDiffPrice(orderbook)
sdPlaceorderSamePrice(orderbook)
sdRemoveOrderSamePrice(orderbook)
sdRemoveOrderDiffPrice(orderbook)