Skip to content

Instantly share code, notes, and snippets.

@EntilZha

EntilZha/Results.txt

Last active Jul 26, 2016
Embed
What would you like to do?
dummy_element_consumer
data_size: 100, passes: 100
grouper_it_0 3 0.003933991072699428
grouper_it_1 3 0.0036308339331299067
grouper_it_2 3 0.0039052229840308428
grouper_impl 3 0.0020833380986005068
grouper_it_0 10 0.0014350449200719595
grouper_it_1 10 0.0015790120232850313
grouper_it_2 10 0.0019499310292303562
grouper_impl 10 0.001163481967523694
grouper_it_0 100 0.0009380229748785496
grouper_it_1 100 0.0008012589532881975
grouper_it_2 100 0.0011698079761117697
grouper_impl 100 0.0007599969394505024
grouper_it_0 1000 0.0009653649758547544
grouper_it_1 1000 0.0008043749257922173
grouper_it_2 1000 0.0011615380644798279
grouper_impl 1000 0.0007657120004296303
grouper_it_0 100000 0.0009718600194901228
grouper_it_1 100000 0.0008252719417214394
grouper_it_2 100000 0.0011472669430077076
grouper_impl 100000 0.0007832539267838001
data_size: 10000, passes: 10
grouper_it_0 3 0.033689730102196336
grouper_it_1 3 0.034385906998068094
grouper_it_2 3 0.03291746089234948
grouper_impl 3 0.030835890909656882
grouper_it_0 10 0.012793408939614892
grouper_it_1 10 0.014853161061182618
grouper_it_2 10 0.014764476101845503
grouper_impl 10 0.01417818502523005
grouper_it_0 100 0.007766809081658721
grouper_it_1 100 0.006616234080865979
grouper_it_2 100 0.006609648000448942
grouper_impl 100 0.00973488506861031
grouper_it_0 1000 0.005960318958386779
grouper_it_1 1000 0.005795323057100177
grouper_it_2 1000 0.005760212196037173
grouper_impl 1000 0.009473436046391726
grouper_it_0 100000 0.009858252946287394
grouper_it_1 100000 0.005814085016027093
grouper_it_2 100000 0.0057585169561207294
grouper_impl 100000 0.009560975013300776
data_size: 1000000, passes: 5
grouper_it_0 3 1.6825837490614504
grouper_it_1 3 1.742024919949472
grouper_it_2 3 1.6676762299612164
grouper_impl 3 1.6323878180701286
grouper_it_0 10 0.6284393819514662
grouper_it_1 10 0.7615351211279631
grouper_it_2 10 0.7397445591632277
grouper_impl 10 1.09273645398207
grouper_it_0 100 0.3821794120594859
grouper_it_1 100 0.3316277898848057
grouper_it_2 100 0.32746461406350136
grouper_impl 100 0.9896876919083297
grouper_it_0 1000 0.3006151111330837
grouper_it_1 1000 0.28577929083257914
grouper_it_2 1000 0.2860563069116324
grouper_impl 1000 0.9473284292034805
grouper_it_0 100000 0.8785911281593144
grouper_it_1 100000 0.27997902291826904
grouper_it_2 100000 0.2802871691528708
grouper_impl 100000 1.1072800441179425
data_size: 10000000, passes: 5
grouper_it_0 3 16.714772118953988
grouper_it_1 3 17.47661661193706
grouper_it_2 3 16.484830127097666
grouper_impl 3 16.578264172188938
grouper_it_0 10 6.348503554938361
grouper_it_1 10 7.510966665809974
grouper_it_2 10 7.361470152856782
grouper_impl 10 11.452303454978392
grouper_it_0 100 3.8636104760225862
grouper_it_1 100 3.290497431065887
grouper_it_2 100 3.2558838999830186
grouper_impl 100 10.27416617795825
grouper_it_0 1000 3.054401748115197
grouper_it_1 1000 2.8619753709062934
grouper_it_2 1000 2.852779987966642
grouper_impl 1000 10.207350737182423
grouper_it_0 100000 5.160557911032811
grouper_it_1 100000 2.8230666092131287
grouper_it_2 100000 2.81491591501981
grouper_impl 100000 11.44517655391246
dummy_chunk_consumer
data_size: 100, passes: 100
grouper_it_0 3 0.003688888857141137
grouper_it_1 3 0.005444845883175731
grouper_it_2 3 0.005767999216914177
grouper_impl 3 0.0025766671169549227
grouper_it_0 10 0.0013114649336785078
grouper_it_1 10 0.0019371178932487965
grouper_it_2 10 0.0022768829949200153
grouper_impl 10 0.0011418778449296951
grouper_it_0 100 0.0007174299098551273
grouper_it_1 100 0.0009363989811390638
grouper_it_2 100 0.0013140561059117317
grouper_impl 100 0.0005849180743098259
grouper_it_0 1000 0.0006880071014165878
grouper_it_1 1000 0.0009578820317983627
grouper_it_2 1000 0.001319214003160596
grouper_impl 1000 0.0006041410379111767
grouper_it_0 100000 0.0006837360560894012
grouper_it_1 100000 0.0009641149081289768
grouper_it_2 100000 0.0013245290610939264
grouper_impl 100000 0.000607938040047884
data_size: 10000, passes: 10
grouper_it_0 3 0.034378133015707135
grouper_it_1 3 0.05137900891713798
grouper_it_2 3 0.04969188803806901
grouper_impl 3 0.029423210071399808
grouper_it_0 10 0.011659668060019612
grouper_it_1 10 0.017611534101888537
grouper_it_2 10 0.017129583982750773
grouper_impl 10 0.014361316105350852
grouper_it_0 100 0.0055935929995030165
grouper_it_1 100 0.006875965977087617
grouper_it_2 100 0.00680185598321259
grouper_impl 100 0.008525124983862042
grouper_it_0 1000 0.0039457709062844515
grouper_it_1 1000 0.004594027996063232
grouper_it_2 1000 0.004659149097278714
grouper_impl 1000 0.008583148010075092
grouper_it_0 100000 0.008142909966409206
grouper_it_1 100000 0.008567200973629951
grouper_it_2 100000 0.009079541079699993
grouper_impl 100000 0.008144360966980457
data_size: 1000000, passes: 5
grouper_it_0 3 1.7186535999644548
grouper_it_1 3 2.5929108110722154
grouper_it_2 3 2.5348269019741565
grouper_impl 3 1.8770926119759679
grouper_it_0 10 0.5832766320090741
grouper_it_1 10 0.8604912550654262
grouper_it_2 10 0.8441140938084573
grouper_impl 10 1.127953896066174
grouper_it_0 100 0.27794667007401586
grouper_it_1 100 0.33801604714244604
grouper_it_2 100 0.32832302805036306
grouper_impl 100 0.9174811060074717
grouper_it_0 1000 0.19781206897459924
grouper_it_1 1000 0.23028366407379508
grouper_it_2 1000 0.2288618648890406
grouper_impl 1000 0.8987088189460337
grouper_it_0 100000 0.7201068601571023
grouper_it_1 100000 0.7494119741022587
grouper_it_2 100000 0.7424005700740963
grouper_impl 100000 1.269335738150403
data_size: 10000000, passes: 5
grouper_it_0 3 17.12352554500103
grouper_it_1 3 26.122539887903258
grouper_it_2 3 25.492529340088367
grouper_impl 3 18.96609855699353
grouper_it_0 10 5.968148723011836
grouper_it_1 10 8.390863701933995
grouper_it_2 10 8.20310752117075
grouper_impl 10 11.679775890894234
grouper_it_0 100 2.774737915955484
grouper_it_1 100 3.4283730890601873
grouper_it_2 100 3.3579553738236427
grouper_impl 100 9.491840851958841
grouper_it_0 1000 1.972270546015352
grouper_it_1 1000 2.2969546529930085
grouper_it_2 1000 2.287172415992245
grouper_impl 1000 9.172432590974495
grouper_it_0 100000 3.694524379912764
grouper_it_1 100000 3.9629707988351583
grouper_it_2 100000 3.986109171062708
grouper_impl 100000 12.846214269986376
import itertools
import timeit
def grouper_it_1(n, iterable):
it = iter(iterable)
while True:
chunk_it = itertools.islice(it, n)
try:
first_el = next(chunk_it)
except StopIteration:
return
yield itertools.chain((first_el,), chunk_it)
def grouper_it_0(n, iterable):
it = iter(iterable)
while True:
chunk = tuple(itertools.islice(it, n))
if not chunk:
return
yield chunk
def grouper_it_2(n, iterable):
it = iter(iterable)
while True:
batch = itertools.islice(it, n)
yield itertools.chain((next(batch),), batch)
def grouper_impl(size, iterable):
sequence = list(iterable)
for i in range(0, len(sequence), size):
yield sequence[i:i + size]
def dummy_element_consumer(func, n=3, data_size=10000):
for chunk in func(n, range(data_size)):
for el in chunk:
dummy = el
def dummy_chunk_consumer(func, n=3, data_size=10000):
for chunk in func(n, range(data_size)):
dummy = tuple(chunk)
if __name__ == '__main__':
for consumer in (dummy_element_consumer, dummy_chunk_consumer):
print(consumer.__name__)
for data_size, npasses in ((100, 100), (10000, 10), (1000000, 5), (10000000, 5)):
print(' data_size: %s, passes: %s' % (data_size, npasses))
for n in (3, 10, 100, 1000, 100000):
print(' grouper_it_0 ', n, timeit.timeit(lambda : consumer(grouper_it_0, n, data_size), number=npasses))
print(' grouper_it_1', n, timeit.timeit(lambda : consumer(grouper_it_1, n, data_size), number=npasses))
print(' grouper_it_2', n, timeit.timeit(lambda : consumer(grouper_it_2, n, data_size), number=npasses))
print(' grouper_impl', n, timeit.timeit(lambda : consumer(grouper_impl, n, data_size), number=npasses))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment