tudasbazis:programozas:python:teljesitmeny_teszt
Összehasonlítás
A kiválasztott és az jelenlegi változat között az alábbi különbségek fordulnak elő:
| tudasbazis:programozas:python:teljesitmeny_teszt [2015.05.12 17:34] – külső szerkesztés 127.0.0.1 | tudasbazis:programozas:python:teljesitmeny_teszt [2015.10.13 13:32] (aktuális) – tia | ||
|---|---|---|---|
| Sor 1: | Sor 1: | ||
| + | ====== Teljesítmény teszt ====== | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * https:// | ||
| + | |||
| + | ===== Futás idő ===== | ||
| + | - Függőségek telepítése: | ||
| + | pip install line_profiler | ||
| + | </ | ||
| + | - Dekoráljuk meg a tesztelendő függvényeket '' | ||
| + | - Indítsuk el speciálisan: | ||
| + | kernprof -l script_to_profile.py | ||
| + | </ | ||
| + | - Nézzük meg az eredményt: <code bash> | ||
| + | python -m line_profiler script_to_profile.py.lprof | ||
| + | </ | ||
| + | Pystone(1.1) time for 50000 passes = 2.48 | ||
| + | This machine benchmarks at 20161.3 pystones/ | ||
| + | Wrote profile results to pystone.py.lprof | ||
| + | Timer unit: 1e-06 s | ||
| + | |||
| + | File: pystone.py | ||
| + | Function: Proc2 at line 149 | ||
| + | Total time: 0.606656 s | ||
| + | |||
| + | Line # Hits | ||
| + | ============================================================== | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Memória ===== | ||
| + | - Függőségek telepítése: | ||
| + | pip install -U memory_profiler | ||
| + | pip install psutil | ||
| + | </ | ||
| + | - Dekoráljuk meg a tesztelendő függvényeket '' | ||
| + | - Indítsuk el speciálisan: | ||
| + | python -m memory_profiler primes.py | ||
| + | </ | ||
| + | Filename: primes.py | ||
| + | |||
| + | Line # Mem usage Increment | ||
| + | ============================================== | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 10 7.9258 MB 0.0000 MB | ||
| + | 11 7.9258 MB 0.0000 MB i=0 | ||
| + | 12 7.9258 MB 0.0000 MB m=3 | ||
| + | 13 7.9297 MB 0.0039 MB while m <= mroot: | ||
| + | 14 7.9297 MB 0.0000 MB if s[i]: | ||
| + | 15 7.9297 MB 0.0000 MB | ||
| + | 16 7.9258 MB -0.0039 MB | ||
| + | 17 7.9297 MB 0.0039 MB while j<half: | ||
| + | 18 7.9297 MB 0.0000 MB | ||
| + | 19 7.9297 MB 0.0000 MB j+=m | ||
| + | 20 7.9297 MB 0.0000 MB i=i+1 | ||
| + | 21 7.9297 MB 0.0000 MB | ||
| + | 22 7.9297 MB 0.0000 MB | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Leak keresés ===== | ||
| + | - Függőségek telepítése: | ||
| + | pip install objgraph | ||
| + | </ | ||
| + | - Kód megállítása '' | ||
| + | - A jelenleg memóriában lévő objektumokról riport kérése: <code python> | ||
| + | import objgraph | ||
| + | objgraph.show_most_common_types() | ||
| + | </ | ||
| + | MyBigFatObject | ||
| + | tuple 16938 | ||
| + | function | ||
| + | dict 2790 | ||
| + | wrapper_descriptor | ||
| + | builtin_function_or_method 934 | ||
| + | weakref | ||
| + | list 634 | ||
| + | method_descriptor | ||
| + | getset_descriptor | ||
| + | type 439 | ||
| + | </ | ||
| + | - Függőségi gráf generálása: | ||
| + | objgraph.show_backref([x], | ||
| + | </ | ||
