[cost] Brush up tests (1)

Summary:
Fix misleading test names. Correct FP/ok/bad markers.
To be continued...

Reviewed By: skcho

Differential Revision: D21905556

fbshipit-source-id: 161801f9c
master
Ezgi Çiçek 5 years ago committed by Facebook GitHub Bot
parent dbdd4413a7
commit 2d6d4f7db9

@ -4,24 +4,27 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
public class A {} class A {}
class B { // The tests in this class were intended to test allocation counts.
// To be revived later once we support them.
void error() { class AllocTest {
void new_alloc_mult() {
A a1 = new A(); A a1 = new A();
A a2 = new A(); A a2 = new A();
A a3 = new A(); A a3 = new A();
A a4 = new A(); A a4 = new A();
} }
void ok() { void new_alloc_one() {
A a1 = new A(); A a1 = new A();
} }
class BArray { class BArray {
void error() { void array_alloc_mult() {
A[] ar1 = new A[5]; A[] ar1 = new A[5];
A[] ar2 = new A[6]; A[] ar2 = new A[6];
A[] ar3 = new A[7]; A[] ar3 = new A[7];
@ -29,9 +32,5 @@ class B {
A[] ar5 = new A[4]; A[] ar5 = new A[4];
} }
void ok() {
A[] ar1 = new A[5];
A[] ar2 = new A[5];
}
} }
} }

@ -10,7 +10,7 @@ import java.util.Arrays;
public class Array { public class Array {
public void array_access_good() { public void array_access_constant() {
float[] radii = new float[8]; float[] radii = new float[8];
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
radii[i * 2] = radii[i]; radii[i * 2] = radii[i];
@ -18,7 +18,7 @@ public class Array {
} }
} }
public void array_access_overrun_bad() { public void array_access_overrun_constant() {
float[] radii = new float[8]; float[] radii = new float[8];
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
radii[i * 2] = radii[i]; radii[i * 2] = radii[i];
@ -26,7 +26,7 @@ public class Array {
} }
} }
void array_access_weird_ok(long[] optionNumerators, int length) { void array_access_weird_linear(long[] optionNumerators, int length) {
for (int j = 0; j < length; ++j) { for (int j = 0; j < length; ++j) {
if (10 < optionNumerators[j] + 1) {} if (10 < optionNumerators[j] + 1) {}
} }
@ -49,7 +49,7 @@ public class Array {
String[] new_arr = Arrays.copyOf(arr, 10); String[] new_arr = Arrays.copyOf(arr, 10);
} }
void init_array_linear() { void init_array_constant() {
int[] table = new int[256]; int[] table = new int[256];
for (int i = 0; i < table.length; ++i) { for (int i = 0; i < table.length; ++i) {
table[i] = i; table[i] = i;

@ -6,7 +6,7 @@
*/ */
public class ArrayCost { public class ArrayCost {
// expected: Theta(mag.length) // expected: O(mag.length)
private void ArrayCost(int[] mag) { private void ArrayCost(int[] mag) {
int i = 0; int i = 0;
@ -17,8 +17,7 @@ public class ArrayCost {
} }
} }
// expected: ~31 private static boolean isPowOfTwo_constant(int value) {
private static boolean isPowOfTwo_FP(int value) {
int ones = 0; int ones = 0;
int v = value; int v = value;

@ -1,18 +1,17 @@
codetoanalyze/java/performance/A.java, A.<init>(), 3, OnUIThread:false, [] codetoanalyze/java/performance/AllocTest.java, A.<init>(), 3, OnUIThread:false, []
codetoanalyze/java/performance/A.java, B$BArray.<init>(B), 6, OnUIThread:false, [] codetoanalyze/java/performance/AllocTest.java, AllocTest$BArray.<init>(AllocTest), 6, OnUIThread:false, []
codetoanalyze/java/performance/A.java, B$BArray.error():void, 11, OnUIThread:false, [] codetoanalyze/java/performance/AllocTest.java, AllocTest$BArray.array_alloc_mult():void, 11, OnUIThread:false, []
codetoanalyze/java/performance/A.java, B$BArray.ok():void, 5, OnUIThread:false, [] codetoanalyze/java/performance/AllocTest.java, AllocTest.<init>(), 3, OnUIThread:false, []
codetoanalyze/java/performance/A.java, B.<init>(), 3, OnUIThread:false, [] codetoanalyze/java/performance/AllocTest.java, AllocTest.new_alloc_mult():void, 21, OnUIThread:false, []
codetoanalyze/java/performance/A.java, B.error():void, 21, OnUIThread:false, [] codetoanalyze/java/performance/AllocTest.java, AllocTest.new_alloc_one():void, 6, OnUIThread:false, []
codetoanalyze/java/performance/A.java, B.ok():void, 6, OnUIThread:false, []
codetoanalyze/java/performance/AndroidXCollectionTest.java, AndroidXCollectionTest.<init>(), 3, OnUIThread:false, [] codetoanalyze/java/performance/AndroidXCollectionTest.java, AndroidXCollectionTest.<init>(), 3, OnUIThread:false, []
codetoanalyze/java/performance/AndroidXCollectionTest.java, AndroidXCollectionTest.call_iterate_over_sparsearraycompat_const():void, 24, OnUIThread:false, [] codetoanalyze/java/performance/AndroidXCollectionTest.java, AndroidXCollectionTest.call_iterate_over_sparsearraycompat_const():void, 24, OnUIThread:false, []
codetoanalyze/java/performance/AndroidXCollectionTest.java, AndroidXCollectionTest.iterate_over_sparsearraycompat_linear(androidx.collection.SparseArrayCompat):void, 8 + 5 ⋅ sa.length, OnUIThread:false, [{sa.length},Loop at line 12] codetoanalyze/java/performance/AndroidXCollectionTest.java, AndroidXCollectionTest.iterate_over_sparsearraycompat_linear(androidx.collection.SparseArrayCompat):void, 8 + 5 ⋅ sa.length, OnUIThread:false, [{sa.length},Loop at line 12]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.<clinit>():void, 9, OnUIThread:false, [] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.<clinit>():void, 9, OnUIThread:false, []
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.<init>(), 3, OnUIThread:false, [] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.<init>(), 3, OnUIThread:false, []
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.array_access_good():void, 70, OnUIThread:false, [] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.array_access_constant():void, 70, OnUIThread:false, []
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.array_access_overrun_bad():void, 70, OnUIThread:false, [] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.array_access_overrun_constant():void, 70, OnUIThread:false, []
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.array_access_weird_ok(long[],int):void, 5 + 13 ⋅ length, OnUIThread:false, [{length},Loop at line 30] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.array_access_weird_linear(long[],int):void, 5 + 13 ⋅ length, OnUIThread:false, [{length},Loop at line 30]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.binary_search_log(java.lang.String[]):int, 5 + log(arr.length), OnUIThread:false, [{arr.length},Modeled call to Arrays.binarySearch] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.binary_search_log(java.lang.String[]):int, 5 + log(arr.length), OnUIThread:false, [{arr.length},Modeled call to Arrays.binarySearch]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.bsearch_log(int):void, 6 + log(i), OnUIThread:false, [{i},Modeled call to Arrays.binarySearch] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.bsearch_log(int):void, 6 + log(i), OnUIThread:false, [{i},Modeled call to Arrays.binarySearch]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.call_gen_and_iter_types(int):void, 19 + 6 ⋅ x + 5 ⋅ x, OnUIThread:false, [{x},call to String[] Array.gen_and_iter_types(int),Loop at line 76,{x},Loop at line 82] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.call_gen_and_iter_types(int):void, 19 + 6 ⋅ x + 5 ⋅ x, OnUIThread:false, [{x},call to String[] Array.gen_and_iter_types(int),Loop at line 76,{x},Loop at line 82]
@ -22,13 +21,13 @@ codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.fill_big_constant():void, 307, OnUIThread:false, [] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.fill_big_constant():void, 307, OnUIThread:false, []
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.fill_linear(java.lang.String[]):void, 2 + arr.length, OnUIThread:false, [{arr.length},Modeled call to Arrays.fill] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.fill_linear(java.lang.String[]):void, 2 + arr.length, OnUIThread:false, [{arr.length},Modeled call to Arrays.fill]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.gen_and_iter_types(int):java.lang.String[], 10 + 5 ⋅ length, OnUIThread:false, [{length},Loop at line 76] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.gen_and_iter_types(int):java.lang.String[], 10 + 5 ⋅ length, OnUIThread:false, [{length},Loop at line 76]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.init_array_linear():void, 2568, OnUIThread:false, [] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.init_array_constant():void, 2568, OnUIThread:false, []
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.sort_array_nlogn(int):void, 5 + size × log(size), OnUIThread:false, [{size},Modeled call to Arrays.sort,{size},Modeled call to Arrays.sort] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.sort_array_nlogn(int):void, 5 + size × log(size), OnUIThread:false, [{size},Modeled call to Arrays.sort,{size},Modeled call to Arrays.sort]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.toArray_linear(java.util.ArrayList):void, 6 + 6 ⋅ list.length + 3 ⋅ (list.length + 1), OnUIThread:false, [{list.length + 1},Loop at line 92,{list.length},Loop at line 92] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.toArray_linear(java.util.ArrayList):void, 6 + 6 ⋅ list.length + 3 ⋅ (list.length + 1), OnUIThread:false, [{list.length + 1},Loop at line 92,{list.length},Loop at line 92]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.use_static_final_array_field_constant():void, 18, OnUIThread:false, [] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.use_static_final_array_field_constant():void, 18, OnUIThread:false, []
codetoanalyze/java/performance/ArrayCost.java, ArrayCost.<init>(), 3, OnUIThread:false, [] codetoanalyze/java/performance/ArrayCost.java, ArrayCost.<init>(), 3, OnUIThread:false, []
codetoanalyze/java/performance/ArrayCost.java, ArrayCost.ArrayCost(int[]):void, 8 + 5 ⋅ mag.length, OnUIThread:false, [{mag.length},Loop at line 15] codetoanalyze/java/performance/ArrayCost.java, ArrayCost.ArrayCost(int[]):void, 8 + 5 ⋅ mag.length, OnUIThread:false, [{mag.length},Loop at line 15]
codetoanalyze/java/performance/ArrayCost.java, ArrayCost.isPowOfTwo_FP(int):boolean, 895, OnUIThread:false, [] codetoanalyze/java/performance/ArrayCost.java, ArrayCost.isPowOfTwo_constant(int):boolean, 895, OnUIThread:false, []
codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest$Elt.<init>(ArrayListTest), 6, OnUIThread:false, [] codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest$Elt.<init>(ArrayListTest), 6, OnUIThread:false, []
codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest$Elt.get_boolean():boolean, 4, OnUIThread:false, [] codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest$Elt.get_boolean():boolean, 4, OnUIThread:false, []
codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.<init>(), 15, OnUIThread:false, [] codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.<init>(), 15, OnUIThread:false, []

@ -1,4 +1,4 @@
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.array_access_overrun_bad():void, 4, BUFFER_OVERRUN_L2, no_bucket, ERROR, [<Offset trace>,Assignment,<Length trace>,Array declaration,Array access: Offset: [2, 8] Size: 8] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.array_access_overrun_constant():void, 4, BUFFER_OVERRUN_L2, no_bucket, ERROR, [<Offset trace>,Assignment,<Length trace>,Array declaration,Array access: Offset: [2, 8] Size: 8]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.call_gen_and_iter_types_linear_FP(int,int):void, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 88] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.call_gen_and_iter_types_linear_FP(int,int):void, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop at line 88]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.call_gen_and_iter_types_linear_FP(int,int):void, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [<LHS trace>,Assignment,Binary operation: ([0, +oo] + 1):signed32] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.call_gen_and_iter_types_linear_FP(int,int):void, 3, INTEGER_OVERFLOW_L5, no_bucket, ERROR, [<LHS trace>,Assignment,Binary operation: ([0, +oo] + 1):signed32]
codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.arraylist_add3_overrun_bad():void, 5, BUFFER_OVERRUN_L1, no_bucket, ERROR, [<Length trace>,Array declaration,Through,Through,Through,Array access: Offset added: 4 Size: 3] codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.arraylist_add3_overrun_bad():void, 5, BUFFER_OVERRUN_L1, no_bucket, ERROR, [<Length trace>,Array declaration,Through,Through,Through,Array access: Offset added: 4 Size: 3]

Loading…
Cancel
Save