実行時の実行で私のメソッドのパフォーマンスの速度を測定したいのですが、私が行ったことが実際にパフォーマンス私の方法は、私が欲しい、または何か他のことをしている。それが私の方法の性能スピードをどれほど信頼できるかよりも測定しているなら。パフォーマンススピードを測定したいメソッドは、FFMulFastと呼ばれ、ガロアフィールド(256)の2つの多項式の乗算を計算します。注:私は自分の質問に関連するコードだけを提示します。Javaで実行時のメソッドのパフォーマンススピードを測定する最も信頼性の高い方法はどれですか
public class GaloaField {
// some fields here
public int FFMulFast(int a, int b){
int t = 0;;
if (a == 0 || b == 0)
return 0;
/* The multiplication is done by using lookup tables. We have used both logarithmic and exponential table for mul
* the idea is firstly look to Logarithmic table then add their powers and find the corresponding of this to exponential table */
t = (Log[(a & 0xff)] & 0xff) + (Log[(b & 0xff)] & 0xff);
if (t > 255) t = t - 255;
return Exp[(t & 0xff)];
}
//some other methods here
public void runABunch() { //method which will measure the performance speed of FFMulFast
long start = System.nanoTime();
int a=0x56;
int b=0xf4;
for (int i = 0; i < 5000000; i++)
FFMulFast(a,b);
long end = System.nanoTime();
System.out.println("Time: " + (end-start));
}
public static void main (String [] args) {
GaloaField galoa=new GaloaField();
galoa.runABunch();
}
私は「最も信頼性の高い」について知らないが、あなたはおそらくプロファイラなどの標準ツールを使用して開始する必要があります。 – markspace
さて、そこにはありません。あなたが測定する時間は、実行はストップウォッチを開始し停止するという2つのイベントの時間差です。しかし、完全なGC、OSがすべてのJVMスレッドを停止したなど、イベントに対するそれらの間で何が起こったかなどはわかりません。だから適切なベンチマークがあるかもしれません - それを行う方法はありますが、正しく、 – micklesh
私はベンチマーキングもしていると思います。 –