Speed tests with a Stream?

オープン
#419 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

Start by running the two standalone benchmark scripts, comparing the generator loop with Stream.from_iterable() and sink_to_list(). Check the streamz documentation and implementation of source.start() and sink_to_list() to determine whether the polling loop is required. Done means documenting the expected performance and the correct standalone-script usage, or identifying a reproducible defect.

索引モデルが issue の本文から書いたものです。

説明

I am trying to compare the speed of operation when a Stream is introduced into the code. These are both scripts that need to be run.

A 'plain' Python example:

from timeit import default_timer as timer
LIMIT = 100000

def sequencer(limit=LIMIT):
    num = 0
    while num < limit:
        yield num
        num += 1

L = []
start = timer()
for i in sequencer():
   L.append(i)

end = timer()
print(end - start)

This takes about 17 milliseconds to run.

An attempt to replicate the above with streamz:

from timeit import default_timer as timer
from streamz import Stream
LIMIT = 100000

def sequencer(limit=LIMIT):
    num = 0
    while num < limit:
        yield num
        num += 1

source = Stream.from_iterable(sequencer())
L = source.sink_to_list()

start = timer()
source.start()
while True:
    if len(L) >= LIMIT:
        break

end = timer()
print(end - start)

This takes about 1200 milliseconds to run. Is this the expected slowdown (two orders-of-magnitude)?

I am not sure though if the streamz code is correct? Its based off of the examples in the docs, but those examples all seem geared towards use in the shell rather than in standalone scripts. If you omit the while True: section, then no data ends up in the output list?

主要言語
Python
スター
1.3k
フォーク
149
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python-streamz/streamz のほかの issue

python-streamz/streamz の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。