差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
python:timeit [2020/03/27 10:08] – [timeit モンキーパッチ] ともやん | python:timeit [2021/07/05 02:38] (現在) – ともやん | ||
---|---|---|---|
行 1: | 行 1: | ||
- | < | ||
- | < | ||
- | #mincode pre { | ||
- | /*height: 300px;*/ | ||
- | overflow: scroll; | ||
- | overflow-x: hidden; | ||
- | font-size: 10px; | ||
- | } | ||
- | # | ||
- | height: 400px; | ||
- | overflow: scroll; | ||
- | overflow-x: hidden; | ||
- | font-size: 10px; | ||
- | } | ||
- | #mintbl table { | ||
- | font-size: 12px; | ||
- | } | ||
- | .dokuwiki .plugin_wrap table { | ||
- | width: auto; | ||
- | } | ||
- | #result pre { | ||
- | /*height: 300px;*/ | ||
- | overflow: scroll; | ||
- | overflow-x: hidden; | ||
- | font-size: 10px; | ||
- | } | ||
- | </ | ||
- | </ | ||
====== timeit ====== | ====== timeit ====== | ||
timeit モジュールは処理の実行時間を計測する。\\ | timeit モジュールは処理の実行時間を計測する。\\ | ||
- | <WRAP prewrap 100% #mincode> | + | <WRAP prewrap 100% mincode> |
<code python dir_walk.py> | <code python dir_walk.py> | ||
# | # | ||
行 80: | 行 52: | ||
timeit.template を変更して、処理時間と戻り値を返却するようする。\\ | timeit.template を変更して、処理時間と戻り値を返却するようする。\\ | ||
**timeit.template (オリジナル)**\\ | **timeit.template (オリジナル)**\\ | ||
- | <WRAP prewrap 100% #mincode> | + | <WRAP prewrap 100% mincode> |
<code python> | <code python> | ||
template = """ | template = """ | ||
行 96: | 行 68: | ||
**timeit.template (モンキーパッチ)**\\ | **timeit.template (モンキーパッチ)**\\ | ||
< | < | ||
- | <WRAP prewrap 100% #mincode> | + | <WRAP prewrap 100% mincode> |
<code python> | <code python> | ||
timeit.template = """ | timeit.template = """ | ||
行 111: | 行 83: | ||
===== timeit.timeit() の実装 ===== | ===== timeit.timeit() の実装 ===== | ||
- | <WRAP prewrap 100% #mincode> | + | <WRAP prewrap 100% mincode> |
<code python> | <code python> | ||
# Don't change the indentation of the template; the reindent() calls | # Don't change the indentation of the template; the reindent() calls | ||
行 128: | 行 100: | ||
</ | </ | ||
- | <WRAP prewrap 100% #mincode_long> | + | <WRAP prewrap 100% mincode_long> |
<code python> | <code python> | ||
class Timer: | class Timer: | ||
行 186: | 行 158: | ||
</ | </ | ||
- | <WRAP prewrap 100% #mincode> | + | <WRAP prewrap 100% mincode> |
<code python> | <code python> | ||
def timeit(stmt=" | def timeit(stmt=" | ||
行 195: | 行 167: | ||
</ | </ | ||
- | <WRAP prewrap 100% #mincode_long> | + | <WRAP prewrap 100% mincode_long> |
<code python Python38/ | <code python Python38/ | ||
#! / | #! / |