[cost] Add PERFORMANCE_VARIATION FP test for Java access methods

Reviewed By: mbouaziz

Differential Revision: D15695390

fbshipit-source-id: 45f6bb68a
master
Ezgi Çiçek 6 years ago committed by Facebook Github Bot
parent 19eac53f0e
commit 19b445e00c

@ -1 +1 @@
{"top":{"current":4,"previous":2},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":6,"previous":4},{"degree":100,"current":2,"previous":4},{"degree":101,"current":4,"previous":0},{"degree":200,"current":0,"previous":4}]}
{"top":{"current":4,"previous":2},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":7,"previous":7},{"degree":100,"current":2,"previous":4},{"degree":101,"current":4,"previous":0},{"degree":200,"current":3,"previous":4}]}

@ -1,5 +1,7 @@
INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, DiffExample.f1(int):void, 0, [Unbounded loop,Loop at line 26]
PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Updated Cost is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 45]
PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample$1.toString():java.lang.String, 0, [Updated Cost is 16 + 13 ⋅ this.this$0.z + 5 ⋅ this.this$0.z × this.this$0.z (degree is 2),{this.this$0.z},call to void DiffExample.f8(int),call to int DiffExample.f4(int),Loop at line 57,{this.this$0.z},call to void DiffExample.f8(int),Loop at line 79]
PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.access$000(int):void, 0, [Updated Cost is 7 + 13 ⋅ x0 + 5 ⋅ x0 × x0 (degree is 2),{x0},call to void DiffExample.f8(int),call to int DiffExample.f4(int),Loop at line 57,{x0},call to void DiffExample.f8(int),Loop at line 79]
INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, DiffExample.f1(int):void, 0, [Unbounded loop,Loop at line 38]
PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Updated Cost is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 57]
PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f5(java.util.ArrayList):void, 0, [Updated Cost is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to Collections.sort,{list.length},Modeled call to Collections.sort]
INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f1(int):void, 0, [Unbounded loop,Loop at line 26]
TIME_COMPLEXITY_INCREASE_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f4(int):int, 0, [Updated Cost is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 45]

@ -1,2 +1,2 @@
INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, DiffExample.f7(int):void, 0, [Call to void DiffExample.f1(int),Unbounded loop,Loop at line 26]
INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, DiffExample.f7(int):void, 0, [Call to void DiffExample.f1(int),Unbounded loop,Loop at line 38]
INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f7(int):void, 0, [Call to void DiffExampleColdStart.f1(int),Unbounded loop,Loop at line 26]

@ -10,6 +10,7 @@ import java.util.ArrayList;
// This class has the following costs:
// 1 bottom (zero), 2 constant, 1 linear, 1 top
// constructor: constant
// private access$000 method for accessing f8
// f1: top
// f2: bottom (zero)
// f3: constant
@ -17,9 +18,20 @@ import java.util.ArrayList;
// f5: n log n
// f6: n log n
// f7: top by call to f1
// f8: quadratic
public class DiffExample {
int z;
ArrayList<String> list =
new ArrayList<String>() {
@Override
public String toString() {
f8(z);
return super.toString();
}
};
// cost: top
private static void f1(int k) {
int i = 0;
@ -61,4 +73,12 @@ public class DiffExample {
private static void f7(int k) {
f1(k);
}
// cost: quadratic
private static void f8(int k) {
for (int i = 0; i < k; i++) {
f4(k);
}
}
}

@ -4,10 +4,13 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import java.util.ArrayList;
// This class has the following costs:
// 2 constant, 1 linear, 1 quadratic
// constructor: constant
// private access$000 method for accessing f4
// f1: linear
// f2: quadratic
// f4: constant
@ -16,6 +19,17 @@
// f7: top
public class DiffExample {
int z;
ArrayList<String> list =
new ArrayList<String>() {
@Override
public String toString() {
f4(z);
return super.toString();
}
};
// cost: linear
private static int f1(int k) {
for (int i = 0; i < k; i++) {

Loading…
Cancel
Save