2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Jupyter Notebook > %timeit range(100) > 処理時間の計測 > %%timeit > 複数文の処理時間の計測

Last updated at Posted at 2016-10-30
動作環境
Ubuntu 14.04 LTS desktop amd64
GeForce GTX 750 Ti
ASRock Z170M Pro4S [Intel Z170chipset]
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v7.5
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.

Jupyter(IPython) NotebookのTutorial
https://www.youtube.com/watch?v=LNncYkzetJg&index=3&list=PLRJx8WOUx5Xd3_dgw5xRmABUd8MWdsA_C

6:02頃

%timeit range(100)

%timeit range(100)

上記でShift+Enter(Run Cells)すると処理時間が表示される。

The slowest run took 4.85 times longer than the fastest. This could mean that an intermediate result is being cached. 1000000 loops, best of 3: 393 ns per loop

%%timeit のあとに複数の実行文

%%timeit

for x in range(100):
    y=x+1

The slowest run took 18.90 times longer than the fastest. This could mean that an intermediate result is being cached. 1000000 loops, best of 3: 1.98 µs per loop

%%timeitの練習

%%timeit

sum=0
i=0
while i<=100000:
    sum+=i
    i+=1

100 loops, best of 3: 3.01 ms per loop

%%timeit
sum=0
for i in xrange(100001):
    sum+=i

1000 loops, best of 3: 1.64 ms per loop

%%timeit
sum(xrange(100001))

1000 loops, best of 3: 526 µs per loop

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?