forked from wrizzhi/quic_client_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
28 lines (23 loc) · 750 Bytes
/
test.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
import random,itertools,struct
from timeit import default_timer as timer
def randbytes(n,_struct8k=struct.Struct("!1000Q").pack_into):
if n<8000:
longs=(n+7)//8
return struct.pack("!%iQ"%longs,*map(
random.getrandbits,itertools.repeat(64,longs)))[:n]
data=bytearray(n);
for offset in range(0,n-7999,8000):
_struct8k(data,offset,
*map(random.getrandbits,itertools.repeat(64,1000)))
offset+=8000
data[offset:]=randbytes(n-offset)
return data
def main():
q = randbytes(n=50000)
start = timer()
info = [q[i:i+950] for i in range(0, len(q), 950)]
end = timer()
print(f'elapsed time: {end - start}')
print(len(info))
if __name__ == '__main__':
main()