示例#1
0
def bench():
    results = [decode(d) for d in file_data]
示例#2
0
from os import listdir
import cProfile
import pstats
from bhencode.decoder import decode
from bhencode.encode import encode


folder_path = '../torrent meta testing samples/'

file_data = []
for file_name in listdir(folder_path):
    with open(folder_path + file_name, 'rb') as f:
        data = f.read()
        file_data.append(data)

python_data = [decode(d) for d in file_data]

for i, obj in enumerate(python_data):
    print('Sample data {0}: {1} .'.format(i, obj))


python_data *= 6000
print('Number of objects to decode: {0}.'.format(len(python_data)))

results = []


def bench():
    global results
    results = [encode(r) for r in python_data]