[cost] Model Collection's contains

Reviewed By: skcho

Differential Revision: D26076519

fbshipit-source-id: f8dce867f
master
Ezgi Çiçek 4 years ago committed by Facebook GitHub Bot
parent 4761e60c5b
commit 0a517db238

@ -279,6 +279,9 @@ module Call = struct
; +PatternMatch.Java.implements_list ; +PatternMatch.Java.implements_list
&:: "contains" <>$ capt_exp &:: "contains" <>$ capt_exp
$+...$--> BoundsOfCollection.linear_length ~of_function:"List.contains" $+...$--> BoundsOfCollection.linear_length ~of_function:"List.contains"
; +PatternMatch.Java.implements_collection
&:: "contains" <>$ capt_exp
$+...$--> BoundsOfCollection.linear_length ~of_function:"Collection.contains"
; +PatternMatch.Java.implements_collections ; +PatternMatch.Java.implements_collections
&:: "binarySearch" <>$ capt_exp &:: "binarySearch" <>$ capt_exp
$+...$--> BoundsOfCollection.logarithmic_length ~of_function:"Collections.binarySearch" $+...$--> BoundsOfCollection.logarithmic_length ~of_function:"Collections.binarySearch"

@ -8,6 +8,7 @@
import android.util.SparseArray; import android.util.SparseArray;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
public class CollectionTest { public class CollectionTest {
@ -102,4 +103,8 @@ public class CollectionTest {
ImmutableSet<Integer> set = ImmutableSet.of(1, 2, 3, 4, 5); ImmutableSet<Integer> set = ImmutableSet.of(1, 2, 3, 4, 5);
for (int i = 0; i < set.size(); i++) {} for (int i = 0; i < set.size(); i++) {}
} }
void containsNull_linear(HashMap<Integer, String> keyMap) {
keyMap.values().contains(null);
}
} }

@ -99,6 +99,7 @@ codetoanalyze/java/performance/CollectionTest.java, CollectionTest$MyEnumType.<i
codetoanalyze/java/performance/CollectionTest.java, CollectionTest$MyEnumType.valueOf(java.lang.String):CollectionTest$MyEnumType, 6, OnUIThread:false, [] codetoanalyze/java/performance/CollectionTest.java, CollectionTest$MyEnumType.valueOf(java.lang.String):CollectionTest$MyEnumType, 6, OnUIThread:false, []
codetoanalyze/java/performance/CollectionTest.java, CollectionTest$MyEnumType.values():CollectionTest$MyEnumType[], 6, OnUIThread:false, [] codetoanalyze/java/performance/CollectionTest.java, CollectionTest$MyEnumType.values():CollectionTest$MyEnumType[], 6, OnUIThread:false, []
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.<init>(), 2, OnUIThread:false, [] codetoanalyze/java/performance/CollectionTest.java, CollectionTest.<init>(), 2, OnUIThread:false, []
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.containsNull_linear(java.util.HashMap):void, 5 + keyMap.length, OnUIThread:false, [{keyMap.length},Modeled call to Collection.contains]
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.ensure_call(CollectionTest$MyCollection):void, 9 + 5 ⋅ list.length, OnUIThread:false, [{list.length},Call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop] codetoanalyze/java/performance/CollectionTest.java, CollectionTest.ensure_call(CollectionTest$MyCollection):void, 9 + 5 ⋅ list.length, OnUIThread:false, [{list.length},Call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop]
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.immutable_set_of_constant():void, 9, OnUIThread:false, [] codetoanalyze/java/performance/CollectionTest.java, CollectionTest.immutable_set_of_constant():void, 9, OnUIThread:false, []
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.immutable_set_of_multiple_constant():void, 64, OnUIThread:false, [] codetoanalyze/java/performance/CollectionTest.java, CollectionTest.immutable_set_of_multiple_constant():void, 64, OnUIThread:false, []

Loading…
Cancel
Save