Mercurial > op > Looping
annotate Looping.py @ 1:9d6fb29e41ce
Objective-C IMPのベンチマークが抜けていたため、追加。
author | "uncorrelated zombie" <uncorrelated@yahoo.co.jp> |
---|---|
date | Tue, 15 Feb 2011 18:38:19 +0900 |
parents | 2216535ade9c |
children | 57283e4fdd4b |
rev | line source |
---|---|
0
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
2 import time |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
3 |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
4 class Looping: |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
5 "Looping Class" |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
6 n0 = 0 |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
7 def calc(self, n): |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
8 n1 = self.n0 + (2 - 2*(n%2)); |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
9 self.n0 = n; |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
10 return n1 |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
11 |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
12 if __name__ == "__main__": |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
13 s = Looping() |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
14 c = 0 |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
15 n = 1 |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
16 t1 = time.time() |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
17 while c<2147483647: |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
18 n = s.calc(n) |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
19 c = c + 1 |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
20 t2 = time.time() |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
21 print n, "Python\t", (t2 - t1) |
2216535ade9c
メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff
changeset
|
22 |