Mercurial > op > Looping
comparison Looping.py @ 0:2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
author | "uncorrelated zombie" <uncorrelated@yahoo.co.jp> |
---|---|
date | Tue, 15 Feb 2011 13:47:19 +0900 |
parents | |
children | 57283e4fdd4b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2216535ade9c |
---|---|
1 #!/usr/bin/env python | |
2 import time | |
3 | |
4 class Looping: | |
5 "Looping Class" | |
6 n0 = 0 | |
7 def calc(self, n): | |
8 n1 = self.n0 + (2 - 2*(n%2)); | |
9 self.n0 = n; | |
10 return n1 | |
11 | |
12 if __name__ == "__main__": | |
13 s = Looping() | |
14 c = 0 | |
15 n = 1 | |
16 t1 = time.time() | |
17 while c<2147483647: | |
18 n = s.calc(n) | |
19 c = c + 1 | |
20 t2 = time.time() | |
21 print n, "Python\t", (t2 - t1) | |
22 |