annotate Looping.java @ 9:30b521e712f5 >>178

JavaScript (xhtml) のソースコードを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Wed, 23 Feb 2011 01:17:31 +0900
parents 2216535ade9c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
1
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
2 public class Looping {
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
3 private int n0;
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
4 public Looping(){
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
5 n0 = 0;
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
6 }
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
7 public int calc(int n){
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
8 int n1 = n0 + (1 - 2*(n%2));
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
9 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 public static void main(String[] args) {
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
13 Looping l = new Looping();
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
14 int n = 1;
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
15 long t1, t2;
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
16 t1 = System.currentTimeMillis();
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
17 for(int c=0;c<Integer.MAX_VALUE;c++){
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
18 n = l.calc(n);
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
19 }
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
20 t2 = System.currentTimeMillis();
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
21 System.out.println(n + "\nJava\t" + (float)(t2 - t1)/1000);
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
22 }
2216535ade9c メンバー関数/メソッド呼び出しのベンチマーク。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
23 }