差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
python:timeit [2020/09/11 17:03] – ともやん | python:timeit [2021/07/05 02:38] (現在) – ともやん | ||
---|---|---|---|
行 2: | 行 2: | ||
timeit モジュールは処理の実行時間を計測する。\\ | timeit モジュールは処理の実行時間を計測する。\\ | ||
- | <WRAP prewrap 100% #mincode> | + | <WRAP prewrap 100% mincode> |
<code python dir_walk.py> | <code python dir_walk.py> | ||
# | # | ||
行 52: | 行 52: | ||
timeit.template を変更して、処理時間と戻り値を返却するようする。\\ | timeit.template を変更して、処理時間と戻り値を返却するようする。\\ | ||
**timeit.template (オリジナル)**\\ | **timeit.template (オリジナル)**\\ | ||
- | <WRAP prewrap 100% #mincode> | + | <WRAP prewrap 100% mincode> |
<code python> | <code python> | ||
template = """ | template = """ | ||
行 68: | 行 68: | ||
**timeit.template (モンキーパッチ)**\\ | **timeit.template (モンキーパッチ)**\\ | ||
< | < | ||
- | <WRAP prewrap 100% #mincode> | + | <WRAP prewrap 100% mincode> |
<code python> | <code python> | ||
timeit.template = """ | timeit.template = """ | ||
行 83: | 行 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 | ||
行 100: | 行 100: | ||
</ | </ | ||
- | <WRAP prewrap 100% #mincode_long> | + | <WRAP prewrap 100% mincode_long> |
<code python> | <code python> | ||
class Timer: | class Timer: | ||
行 158: | 行 158: | ||
</ | </ | ||
- | <WRAP prewrap 100% #mincode> | + | <WRAP prewrap 100% mincode> |
<code python> | <code python> | ||
def timeit(stmt=" | def timeit(stmt=" | ||
行 167: | 行 167: | ||
</ | </ | ||
- | <WRAP prewrap 100% #mincode_long> | + | <WRAP prewrap 100% mincode_long> |
<code python Python38/ | <code python Python38/ | ||
#! / | #! / |