How to specify setup code with Runner.bench_func() ?
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- performance, tooling
Direzione di ricerca
Inizia con Runner.bench_func() e il comportamento di subprocess(main) mostrato nell’esempio fornito; leggi anche l’issue correlata 28. Riproduci la costruzione ripetuta di BenchModule, quindi verifica che il setup richiesto venga eseguito una sola volta tra le esecuzioni dei benchmark, mentre i benchmark continuano a essere eseguiti normalmente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I am trying to bench some data structures with a large number of items in each structure. I would like to have a single setup that is called once (and only once) for all benchmark runs, because the setup takes several seconds to complete.
While debugging, I discovered this very peculiar behavior that perf reloads the entire main module for each run.
import perf
import time
def run_benchmarks(module):
runner = perf.Runner()
def get_doc(attr):
return getattr(module, attr).__doc__
bench_names = sorted([ x for x in dir(module) if x.startswith('bench_') ], key=get_doc)
for bench_name in bench_names:
bench = getattr(module, bench_name)
doc = bench.__doc__
print('Running: %s' % (doc))
runner.bench_func(doc, bench)
class BenchModule(object):
def __init__(self):
print('Creating BenchModule()')
time.sleep(3)
print('Created BenchModule()')
def bench_foo(self):
'''Benchmark: foo'''
return list(range(1000))
def bench_bar(self):
'''Benchmark: bar'''
return list(range(1000))
if __name__ == '__main__':
print('Starting benchmarks')
module = BenchModule()
run_benchmarks(module)
When I run this, I see output like the following:
Starting benchmarks
Creating BenchModule()
Created BenchModule()
Running: Benchmark: bar
Starting benchmarks
Creating BenchModule()
Created BenchModule()
Running: Benchmark: bar
Running: Benchmark: foo
.Starting benchmarks
Creating BenchModule()
Created BenchModule()
Running: Benchmark: bar
Running: Benchmark: foo
.Starting benchmarks
Creating BenchModule()
Created BenchModule()
Running: Benchmark: bar
Running: Benchmark: foo
.Starting benchmarks
Creating BenchModule()
[ ... snip ... ]
.Starting benchmarks
Creating BenchModule()
Created BenchModule()
Running: Benchmark: bar
Running: Benchmark: foo
.
Benchmark: foo: Mean +- std dev: 9.83 us +- 0.16 us
... what the ? 😖
Why is it printing my Starting benchmarks line more than once? More importantly, how is it doing this? Is there some black magic going on with subprocess(__main__)?
But back to the original issue that lead me down this rathole; how do I prevent perf from running my BenchModule constructor on each run? I put a 3-second sleep in there to illustrate why the current behavior is obnoxious. In my real world benchmark, the setup time is more than 30 seconds, and running the complete test suite lasts a few hours.
This is possibly related: https://github.com/vstinner/perf/issues/28
- Lingua principale
- Python
- Stelle
- 967
- Fork
- 112
- Merge medio
- 5g 8h
- PR unite (30g)
- 9
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di psf/pyperf
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Improve Type System for `pyperf`Forse già presa @DebanKsahu l’ha presa 69 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 32/100
I maintainer di solito rispondono entro 1 giorno
-
Extend hook's teardown metadata with warmup/calibration flagsForse già presa @maurycy l’ha presa 170 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
psf/pyperf#239 · 12 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
add entry to blockAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"Forse già presa @0z5a l’ha presa oggi. Apertaneeds-triage
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
plot_graph crashes when a mesh node has no m2m edgeForse già presa @tygvi l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
mllam/neural-lam#883 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
future-agi/future-agi#4092 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
transcript analytics: a text whose only protected spans the prose pass redacts is withheld wholeAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
WingedGuardian/GENesis-AGI#4641 ·
I maintainer di solito rispondono entro 1 giorno