| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.util; |
| 17 |
|
| 18 |
import android.util.FloatMath; |
| 19 |
|
| 20 |
public class FloatMathBenchmark { |
| 21 |
|
| 22 |
public float timeFloatMathCeil(int reps) { |
| 23 |
|
| 24 |
float f = 0.0f; |
| 25 |
for (int i = 0; i < reps; i++) { |
| 26 |
f += FloatMath.ceil(100.123f); |
| 27 |
} |
| 28 |
return f; |
| 29 |
} |
| 30 |
|
| 31 |
public float timeFloatMathCeil_math(int reps) { |
| 32 |
|
| 33 |
float f = 0.0f; |
| 34 |
for (int i = 0; i < reps; i++) { |
| 35 |
f += (float) Math.ceil(100.123f); |
| 36 |
} |
| 37 |
return f; |
| 38 |
} |
| 39 |
|
| 40 |
public float timeFloatMathCos(int reps) { |
| 41 |
|
| 42 |
float f = 0.0f; |
| 43 |
for (int i = 0; i < reps; i++) { |
| 44 |
f += FloatMath.cos(100.123f); |
| 45 |
} |
| 46 |
return f; |
| 47 |
} |
| 48 |
|
| 49 |
public float timeFloatMathExp(int reps) { |
| 50 |
|
| 51 |
float f = 0.0f; |
| 52 |
for (int i = 0; i < reps; i++) { |
| 53 |
f += FloatMath.exp(100.123f); |
| 54 |
} |
| 55 |
return f; |
| 56 |
} |
| 57 |
|
| 58 |
public float timeFloatMathFloor(int reps) { |
| 59 |
|
| 60 |
float f = 0.0f; |
| 61 |
for (int i = 0; i < reps; i++) { |
| 62 |
f += FloatMath.floor(100.123f); |
| 63 |
} |
| 64 |
return f; |
| 65 |
} |
| 66 |
|
| 67 |
public float timeFloatMathHypot(int reps) { |
| 68 |
|
| 69 |
float f = 0.0f; |
| 70 |
for (int i = 0; i < reps; i++) { |
| 71 |
f += FloatMath.hypot(100.123f, 100.123f); |
| 72 |
} |
| 73 |
return f; |
| 74 |
} |
| 75 |
|
| 76 |
public float timeFloatMathPow(int reps) { |
| 77 |
|
| 78 |
float f = 0.0f; |
| 79 |
for (int i = 0; i < reps; i++) { |
| 80 |
f += FloatMath.pow(10.123f, 10.123f); |
| 81 |
} |
| 82 |
return f; |
| 83 |
} |
| 84 |
|
| 85 |
public float timeFloatMathSin(int reps) { |
| 86 |
|
| 87 |
float f = 0.0f; |
| 88 |
for (int i = 0; i < reps; i++) { |
| 89 |
f += FloatMath.sin(100.123f); |
| 90 |
} |
| 91 |
return f; |
| 92 |
} |
| 93 |
|
| 94 |
public float timeFloatMathSqrt(int reps) { |
| 95 |
|
| 96 |
float f = 0.0f; |
| 97 |
for (int i = 0; i < reps; i++) { |
| 98 |
f += FloatMath.sqrt(100.123f); |
| 99 |
} |
| 100 |
return f; |
| 101 |
} |
| 102 |
|
| 103 |
public float timeFloatMathSqrt_math(int reps) { |
| 104 |
|
| 105 |
float f = 0.0f; |
| 106 |
for (int i = 0; i < reps; i++) { |
| 107 |
f += (float) Math.sqrt(100.123f); |
| 108 |
} |
| 109 |
return f; |
| 110 |
} |
| 111 |
} |