[cost] Remove cold-start issues

Summary:
We stopped relying on an external perf data file to determine which functions are on the cold start. Let's remove this issue now.

NB: Keeping the `--perf-profiler-data-file` as deprecated to prevent issues on the CI and prod.

Reviewed By: skcho

Differential Revision: D21594150

fbshipit-source-id: faa58782d
master
Ezgi Çiçek 5 years ago committed by Facebook GitHub Bot
parent 8a0d584121
commit 4f97296e55

@ -201,7 +201,7 @@ OPTIONS
(Conversely: --no-loop-hoisting-only)
--perf-profiler-data-file file
Specify the file containing perf profiler data to read
DEPRECATED: Specify the file containing perf profiler data to read
--print-active-checkers
Activates: Print the active checkers before starting the analysis

@ -421,13 +421,10 @@ OPTIONS
ERADICATE_UNVETTED_THIRD_PARTY_IN_NULLSAFE (enabled by
default),
EXECUTION_TIME_COMPLEXITY_INCREASE (enabled by default),
EXECUTION_TIME_COMPLEXITY_INCREASE_COLD_START (enabled by
default),
EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD (enabled by
default),
EXECUTION_TIME_UNREACHABLE_AT_EXIT (disabled by default),
EXPENSIVE_EXECUTION_TIME (disabled by default),
EXPENSIVE_EXECUTION_TIME_COLD_START (disabled by default),
EXPENSIVE_EXECUTION_TIME_UI_THREAD (disabled by default),
EXPENSIVE_LOOP_INVARIANT_CALL (enabled by default),
EXPOSED_INSECURE_INTENT_HANDLING (enabled by default),
@ -782,7 +779,7 @@ OPTIONS
See also infer-analyze(1).
--perf-profiler-data-file file
Specify the file containing perf profiler data to read
DEPRECATED: Specify the file containing perf profiler data to read
See also infer-analyze(1).
--print-active-checkers

@ -151,13 +151,10 @@ OPTIONS
ERADICATE_UNVETTED_THIRD_PARTY_IN_NULLSAFE (enabled by
default),
EXECUTION_TIME_COMPLEXITY_INCREASE (enabled by default),
EXECUTION_TIME_COMPLEXITY_INCREASE_COLD_START (enabled by
default),
EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD (enabled by
default),
EXECUTION_TIME_UNREACHABLE_AT_EXIT (disabled by default),
EXPENSIVE_EXECUTION_TIME (disabled by default),
EXPENSIVE_EXECUTION_TIME_COLD_START (disabled by default),
EXPENSIVE_EXECUTION_TIME_UI_THREAD (disabled by default),
EXPENSIVE_LOOP_INVARIANT_CALL (enabled by default),
EXPOSED_INSECURE_INTENT_HANDLING (enabled by default),

@ -421,13 +421,10 @@ OPTIONS
ERADICATE_UNVETTED_THIRD_PARTY_IN_NULLSAFE (enabled by
default),
EXECUTION_TIME_COMPLEXITY_INCREASE (enabled by default),
EXECUTION_TIME_COMPLEXITY_INCREASE_COLD_START (enabled by
default),
EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD (enabled by
default),
EXECUTION_TIME_UNREACHABLE_AT_EXIT (disabled by default),
EXPENSIVE_EXECUTION_TIME (disabled by default),
EXPENSIVE_EXECUTION_TIME_COLD_START (disabled by default),
EXPENSIVE_EXECUTION_TIME_UI_THREAD (disabled by default),
EXPENSIVE_LOOP_INVARIANT_CALL (enabled by default),
EXPOSED_INSECURE_INTENT_HANDLING (enabled by default),
@ -782,7 +779,7 @@ OPTIONS
See also infer-analyze(1).
--perf-profiler-data-file file
Specify the file containing perf profiler data to read
DEPRECATED: Specify the file containing perf profiler data to read
See also infer-analyze(1).
--print-active-checkers

@ -1,100 +0,0 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
module L = Logging
module PerfProfilerDataMap = Caml.Map.Make (struct
type t = Procname.t
let compare = Procname.compare
end)
let global_perf_profiler_data : Perf_profiler_t.perf_profiler_item PerfProfilerDataMap.t ref =
ref PerfProfilerDataMap.empty
let split_class_method_name =
let class_sep = String.Search_pattern.create "::" in
fun qualified_method_name ->
match String.Search_pattern.index class_sep ~in_:qualified_method_name with
| Some class_sep_pos ->
let class_name =
String.sub qualified_method_name ~pos:0 ~len:class_sep_pos
|> String.tr ~target:'/' ~replacement:'.'
in
let method_name =
let prefix_len = class_sep_pos + 2 in
String.sub qualified_method_name ~pos:prefix_len
~len:(String.length qualified_method_name - prefix_len)
in
Some (class_name, method_name)
| _ ->
None
let pp_perf_profiler_item itm =
let open Perf_profiler_t in
L.(debug Analysis Medium)
"@\n\n\
\ [Perf Profiler Log] Function: '%s' @\n\
\ count trace id = %i @\n\
\ sum inclusive cpu time = %f@\n\
\ avg inclusive time = %f @\n\
\ sum exclusive cpu time = %f @\n\
\ avg exclusive_time = %f @\n"
itm.function_name itm.approx_count_trace_id itm.sum_inclusive_cpu_time
itm.avg_inclusive_cpu_time_ms itm.sum_exclusive_cpu_time itm.avg_exclusive_cpu_time_ms
let _read_file_perf_data fname =
let perf_profiler_data_str =
match Utils.read_file fname with
| Ok l ->
List.map ~f:Perf_profiler_j.perf_profiler_of_string l
| Error error ->
L.user_error "Failed to read file '%s': %s@." fname error ;
[]
in
let do_item itm =
pp_perf_profiler_item itm ;
match split_class_method_name itm.Perf_profiler_t.function_name with
| Some (classname, methodname) ->
let procname = JProcname.make_void_signature_procname ~classname ~methodname in
global_perf_profiler_data := PerfProfilerDataMap.add procname itm !global_perf_profiler_data
| _ ->
()
in
List.iter ~f:(fun items -> List.iter ~f:do_item items) perf_profiler_data_str
let read_file_flag = ref false
let prepare_perf_data fname =
if not !read_file_flag then (
_read_file_perf_data fname ;
read_file_flag := true ) ;
if PerfProfilerDataMap.is_empty !global_perf_profiler_data then
L.(debug Analysis Medium) "@\n\n[Perf Profiler Log] WARNING: EMPTY PERF PROFILER DATA@\n"
let in_profiler_data_map key =
match Config.perf_profiler_data_file with
| Some fname ->
prepare_perf_data fname ;
PerfProfilerDataMap.mem key !global_perf_profiler_data
| _ ->
false
let get_avg_inclusive_time_opt key =
let open IOption.Let_syntax in
let* fname = Config.perf_profiler_data_file in
prepare_perf_data fname ;
let+ {Perf_profiler_t.avg_inclusive_cpu_time_ms} =
PerfProfilerDataMap.find_opt key !global_perf_profiler_data
in
avg_inclusive_cpu_time_ms

@ -1,12 +0,0 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
val in_profiler_data_map : Procname.t -> bool
val get_avg_inclusive_time_opt : Procname.t -> float option

@ -274,8 +274,3 @@ let create_procname ~classname ~methodname:method_name ~signature ~use_signature
in
Procname.make_java ~class_name ~return_type ~method_name ~parameters
~kind:Procname.Java.Non_Static ()
let make_void_signature_procname ~classname ~methodname =
let signature = JNI.void_method_with_no_arguments in
create_procname ~signature ~classname ~methodname ~use_signature:true

@ -41,5 +41,3 @@ end
val create_procname :
classname:string -> methodname:string -> signature:string -> use_signature:bool -> Procname.t
val make_void_signature_procname : classname:string -> methodname:string -> Procname.t

@ -56,19 +56,6 @@
(deps java_method_decl.atd)
(action (run atdgen -t %{deps})))
; ATD for perf_profiler
(rule
(targets perf_profiler_j.ml
perf_profiler_j.mli)
(deps perf_profiler.atd)
(action (run atdgen -j -j-std %{deps})))
(rule
(targets perf_profiler_t.ml
perf_profiler_t.mli)
(deps perf_profiler.atd)
(action (run atdgen -t %{deps})))
; ATD for java_profiler_samples
(rule
(targets java_profiler_samples_j.ml

@ -1,17 +0,0 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
type perf_profiler_item = {
function_name: string;
approx_count_trace_id: int;
sum_inclusive_cpu_time: float;
avg_inclusive_cpu_time_ms: float;
sum_exclusive_cpu_time: float;
avg_exclusive_cpu_time_ms: float;
}
type perf_profiler = perf_profiler_item list

@ -1451,10 +1451,10 @@ and _log_skipped =
machine-readable format"
and perf_profiler_data_file =
and[@warning "-32"] perf_profiler_data_file =
CLOpt.mk_path_opt ~long:"perf-profiler-data-file"
~in_help:InferCommand.[(Analyze, manual_generic)]
~meta:"file" "Specify the file containing perf profiler data to read"
~meta:"file" "DEPRECATED: Specify the file containing perf profiler data to read"
and linter =
@ -2775,8 +2775,6 @@ and load_average =
match !load_average with None when !buck -> Some (float_of_int ncpu) | _ -> !load_average
and perf_profiler_data_file = !perf_profiler_data_file
and max_nesting = !max_nesting
and method_decls_info = !method_decls_info

@ -409,8 +409,6 @@ val only_cheap_debug : bool
val only_footprint : bool
val perf_profiler_data_file : string option
val print_active_checkers : bool
val print_builtins : bool

@ -10,8 +10,8 @@ type issue_spec =
{ extract_cost_f: Jsonbug_t.cost_item -> Jsonbug_t.cost_info
; name: string
; threshold: int option
; complexity_increase_issue: is_on_cold_start:bool -> is_on_ui_thread:bool -> IssueType.t
; expensive_issue: is_on_cold_start:bool -> is_on_ui_thread:bool -> IssueType.t
; complexity_increase_issue: is_on_ui_thread:bool -> IssueType.t
; expensive_issue: is_on_ui_thread:bool -> IssueType.t
; unreachable_issue: IssueType.t
; infinite_issue: IssueType.t
; top_and_unreachable: bool }
@ -40,11 +40,9 @@ let enabled_cost_map =
; threshold= (if Config.use_cost_threshold then CostKind.to_threshold kind else None)
; extract_cost_f= (fun c -> CostKind.to_json_cost_info c kind)
; complexity_increase_issue=
(fun ~is_on_cold_start ~is_on_ui_thread ->
IssueType.complexity_increase ~kind ~is_on_cold_start ~is_on_ui_thread )
(fun ~is_on_ui_thread -> IssueType.complexity_increase ~kind ~is_on_ui_thread)
; expensive_issue=
(fun ~is_on_cold_start ~is_on_ui_thread ->
IssueType.expensive_cost_call ~kind ~is_on_cold_start ~is_on_ui_thread )
(fun ~is_on_ui_thread -> IssueType.expensive_cost_call ~kind ~is_on_ui_thread)
; unreachable_issue= IssueType.unreachable_cost_call ~kind
; infinite_issue= IssueType.infinite_cost_call ~kind
; top_and_unreachable }

@ -11,8 +11,8 @@ type issue_spec =
{ extract_cost_f: Jsonbug_t.cost_item -> Jsonbug_t.cost_info
; name: string
; threshold: int option
; complexity_increase_issue: is_on_cold_start:bool -> is_on_ui_thread:bool -> IssueType.t
; expensive_issue: is_on_cold_start:bool -> is_on_ui_thread:bool -> IssueType.t
; complexity_increase_issue: is_on_ui_thread:bool -> IssueType.t
; expensive_issue: is_on_ui_thread:bool -> IssueType.t
; unreachable_issue: IssueType.t
; infinite_issue: IssueType.t
; top_and_unreachable: bool }

@ -24,7 +24,6 @@ module Unsafe : sig
val register_from_cost_string :
?enabled:bool
-> ?is_on_cold_start:bool
-> ?is_on_ui_thread:bool
-> kind:CostKind.t
-> (string -> string, Format.formatter, unit, string) format4
@ -88,14 +87,10 @@ end = struct
(** cost issues are already registered below.*)
let register_from_cost_string ?(enabled = true) ?(is_on_cold_start = false)
?(is_on_ui_thread = false) ~(kind : CostKind.t) s =
let register_from_cost_string ?(enabled = true) ?(is_on_ui_thread = false) ~(kind : CostKind.t) s
=
let issue_type_base = Format.asprintf s (CostKind.to_issue_string kind) in
let issue_type =
if is_on_ui_thread then issue_type_base ^ "_UI_THREAD"
else if is_on_cold_start then issue_type_base ^ "_COLD_START"
else issue_type_base
in
let issue_type = if is_on_ui_thread then issue_type_base ^ "_UI_THREAD" else issue_type_base in
register_from_string ~enabled issue_type
@ -325,8 +320,8 @@ let eradicate_meta_class_can_be_nullsafe =
(* Should be enabled for special integrations *) ~enabled:false
let expensive_cost_call ~kind ~is_on_cold_start ~is_on_ui_thread =
register_from_cost_string ~enabled:false ~kind ~is_on_cold_start ~is_on_ui_thread "EXPENSIVE_%s"
let expensive_cost_call ~kind ~is_on_ui_thread =
register_from_cost_string ~enabled:false ~kind ~is_on_ui_thread "EXPENSIVE_%s"
let exposed_insecure_intent_handling = register_from_string "EXPOSED_INSECURE_INTENT_HANDLING"
@ -480,8 +475,8 @@ let symexec_memory_error =
let thread_safety_violation = register_from_string "THREAD_SAFETY_VIOLATION"
let complexity_increase ~kind ~is_on_cold_start ~is_on_ui_thread =
register_from_cost_string ~kind ~is_on_cold_start ~is_on_ui_thread "%s_COMPLEXITY_INCREASE"
let complexity_increase ~kind ~is_on_ui_thread =
register_from_cost_string ~kind ~is_on_ui_thread "%s_COMPLEXITY_INCREASE"
let topl_error = register_from_string "TOPL_ERROR"
@ -541,10 +536,9 @@ let unreachable_cost_call ~kind =
(* register enabled cost issues *)
let () =
List.iter CostKind.enabled_cost_kinds ~f:(fun CostKind.{kind} ->
List.iter [true; false] ~f:(fun is_on_cold_start ->
List.iter [true; false] ~f:(fun is_on_ui_thread ->
let _ = unreachable_cost_call ~kind in
let _ = expensive_cost_call ~kind ~is_on_cold_start ~is_on_ui_thread in
let _ = infinite_cost_call ~kind in
let _ = complexity_increase ~kind ~is_on_cold_start ~is_on_ui_thread in
() ) ) )
List.iter [true; false] ~f:(fun is_on_ui_thread ->
let _ = unreachable_cost_call ~kind in
let _ = expensive_cost_call ~kind ~is_on_ui_thread in
let _ = infinite_cost_call ~kind in
let _ = complexity_increase ~kind ~is_on_ui_thread in
() ) )

@ -103,7 +103,7 @@ val codequery : t
val comparing_floats_for_equality : t
val complexity_increase : kind:CostKind.t -> is_on_cold_start:bool -> is_on_ui_thread:bool -> t
val complexity_increase : kind:CostKind.t -> is_on_ui_thread:bool -> t
val component_factory_function : t
@ -180,7 +180,7 @@ val eradicate_meta_class_needs_improvement : t
val eradicate_meta_class_is_nullsafe : t
val expensive_cost_call : kind:CostKind.t -> is_on_cold_start:bool -> is_on_ui_thread:bool -> t
val expensive_cost_call : kind:CostKind.t -> is_on_ui_thread:bool -> t
val exposed_insecure_intent_handling : t

@ -240,8 +240,7 @@ module Check = struct
~threshold ~is_on_ui_thread =
let report_issue_type =
L.(debug Analysis Medium) "@\n\n++++++ Checking error type for %a **** @\n" Procname.pp pname ;
let is_on_cold_start = ExternalPerfData.in_profiler_data_map pname in
expensive_issue ~is_on_cold_start ~is_on_ui_thread
expensive_issue ~is_on_ui_thread
in
let bigO_str =
Format.asprintf ", %a"

@ -40,7 +40,6 @@ let () =
; LivenessTests.tests
; LRUHashtblTests.tests
; MaximumSharingTests.tests
; PerfProfilerATDParserTest.tests
; ProcCfgTests.tests
; RestartSchedulerTests.tests
; SchedulerTests.tests

@ -212,23 +212,11 @@ let issue_of_cost kind CostIssues.{complexity_increase_issue; unreachable_issue;
let file = cost_info.Jsonbug_t.loc.file in
let method_name = cost_info.Jsonbug_t.procedure_name in
let is_on_ui_thread = cost_info.Jsonbug_t.is_on_ui_thread in
let class_name =
match Str.split (Str.regexp_string ("." ^ method_name)) cost_info.Jsonbug_t.procedure_id with
| [class_name; _] ->
class_name
| _ ->
""
in
let procname =
JProcname.make_void_signature_procname ~classname:class_name ~methodname:method_name
in
let source_file = SourceFile.create ~warn_on_error:false file in
let issue_type =
if CostItem.is_top curr_item then infinite_issue
else if CostItem.is_unreachable curr_item then unreachable_issue
else
let is_on_cold_start = ExternalPerfData.in_profiler_data_map procname in
complexity_increase_issue ~is_on_cold_start ~is_on_ui_thread
else complexity_increase_issue ~is_on_ui_thread
in
if (not Config.filtering) || issue_type.IssueType.enabled then
let qualifier =
@ -246,20 +234,6 @@ let issue_of_cost kind CostIssues.{complexity_increase_issue; unreachable_issue;
"Please make sure this is an expected change. You can inspect the trace to understand \
the complexity increase:"
in
let cold_start_or_ui_msg =
let common_msg = "It is very important to avoid potential regressions in this phase." in
if is_on_ui_thread then
Format.asprintf "%a %s" MarkupFormatter.pp_bold
"This function is called on the UI Thread!" common_msg
else
Option.value_map (ExternalPerfData.get_avg_inclusive_time_opt procname) ~default:""
~f:(fun avg_inclusive_time ->
let pp_avg_inclusive_time f =
Format.fprintf f "(avg inclusive CPU time was %.1f ms)" avg_inclusive_time
in
Format.asprintf "%a %t %s" MarkupFormatter.pp_bold
"This function is called during cold start!" pp_avg_inclusive_time common_msg )
in
let msg f =
(* Java Only *)
if String.equal method_name Procname.Java.constructor_method_name then
@ -269,7 +243,7 @@ let issue_of_cost kind CostIssues.{complexity_increase_issue; unreachable_issue;
else
Format.fprintf f "%a" (MarkupFormatter.wrap_monospaced Format.pp_print_string) method_name
in
Format.asprintf "%s of %t has %a from %a to %a. %s %a"
Format.asprintf "%s of %t has %a from %a to %a. %a"
(CostKind.to_complexity_string kind)
msg
(MarkupFormatter.wrap_bold pp_delta)
@ -277,7 +251,7 @@ let issue_of_cost kind CostIssues.{complexity_increase_issue; unreachable_issue;
(MarkupFormatter.wrap_monospaced (CostItem.pp_degree ~only_bigO:true))
prev_item
(MarkupFormatter.wrap_monospaced (CostItem.pp_degree ~only_bigO:true))
curr_item cold_start_or_ui_msg pp_extra_msg ()
curr_item pp_extra_msg ()
in
let line = cost_info.Jsonbug_t.loc.lnum in
let column = cost_info.Jsonbug_t.loc.cnum in

@ -1,35 +0,0 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
open OUnit2
let test_parser =
let create_test input expected _ =
let found = Perf_profiler_j.perf_profiler_of_string input in
assert_equal expected found
in
[ ("test_parser_1", "[]", [])
; ( "test_parser_2"
, {|[{"function_name":"pkg/cls::\u003Cclinit>",
"approx_count_trace_id": 2,
"sum_inclusive_cpu_time": 34.4324324,
"avg_inclusive_cpu_time_ms":123.01234567899,
"sum_exclusive_cpu_time": 17.4543543,
"avg_exclusive_cpu_time_ms":9.8765432123456
}]|}
, [ { Perf_profiler_t.function_name= "pkg/cls::<clinit>"
; approx_count_trace_id= 2
; sum_inclusive_cpu_time= 34.4324324
; avg_inclusive_cpu_time_ms= 123.01234567899
; sum_exclusive_cpu_time= 17.4543543
; avg_exclusive_cpu_time_ms= 9.8765432123456 } ] ) ]
|> List.map ~f:(fun (name, test_input, expected_output) ->
name >:: create_test test_input expected_output )
let tests = "java_profiler_samples" >::: test_parser

@ -6,7 +6,7 @@
# E2E test for differential of costs
TESTS_DIR = ../..
SOURCES = src/DiffExample.java.current src/DiffExample.java.previous src/DiffExampleColdStart.java.current src/DiffExampleColdStart.java.previous src/DiffExampleUIThread.java.current src/DiffExampleUIThread.java.previous
SOURCES = src/DiffExample.java.current src/DiffExample.java.previous src/DiffExampleUIThread.java.current src/DiffExampleUIThread.java.previous
CLEAN_EXTRA = src/Diff*.java *.class
include $(TESTS_DIR)/differential.make
include $(TESTS_DIR)/java.make
@ -17,14 +17,12 @@ $(CURRENT_REPORT) $(PREVIOUS_REPORT): $(JAVA_DEPS)
$(CURRENT_REPORT):
$(QUIET)$(COPY) src/DiffExample.java.current src/DiffExample.java
$(QUIET)$(COPY) src/DiffExampleColdStart.java.current src/DiffExampleColdStart.java
$(QUIET)$(COPY) src/DiffExampleUIThread.java.current src/DiffExampleUIThread.java
$(QUIET)$(call silent_on_success,Testing Cost Differential: current,\
$(INFER_BIN) --enable-issue-type INFINITE_EXECUTION_TIME --cost-only -o $(CURRENT_DIR) -- $(JAVAC) -cp $(CLASSPATH) src/*.java)
$(PREVIOUS_REPORT):
$(QUIET)$(COPY) src/DiffExample.java.previous src/DiffExample.java
$(QUIET)$(COPY) src/DiffExampleColdStart.java.previous src/DiffExampleColdStart.java
$(QUIET)$(COPY) src/DiffExampleUIThread.java.previous src/DiffExampleUIThread.java
$(QUIET)$(call silent_on_success,Testing Cost Differential: previous,\
$(INFER_BIN) --debug --enable-issue-type INFINITE_EXECUTION_TIME --cost-only -o $(PREVIOUS_DIR) -- $(JAVAC) -cp $(CLASSPATH) src/*.java)

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

@ -1,3 +1,2 @@
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f6(java.util.ArrayList):void, 0, [Updated Cost of f6 is 5 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},call to void DiffExample.f5(ArrayList),Modeled call to Collections.sort,{list.length},call to void DiffExample.f5(ArrayList),Modeled call to Collections.sort]
EXECUTION_TIME_COMPLEXITY_INCREASE_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f6(java.util.ArrayList):void, 0, [Updated Cost of f6 is 5 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to Collections.sort,{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to Collections.sort]
EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD, no_bucket, src/DiffExampleUIThread.java, DiffExampleUIThread.f1(int):void, 0, [Updated Cost of f1 is 3 (degree is 0)]

@ -1,7 +1,4 @@
INFINITE_EXECUTION_TIME, no_bucket, src/DiffExample.java, DiffExample.f1(int):void, 0, [Unbounded loop,Loop at line 38]
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Updated Cost of f4 is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 57]
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f5(java.util.ArrayList):void, 0, [Updated Cost of f5 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, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f1(int):void, 0, [Unbounded loop,Loop at line 26]
EXECUTION_TIME_COMPLEXITY_INCREASE_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f4(int):int, 0, [Updated Cost of f4 is 6 + 7 ⋅ k (degree is 1),{k},Loop at line 45]
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f5(java.util.ArrayList):void, 0, [Updated Cost of f5 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]
EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD, no_bucket, src/DiffExampleUIThread.java, DiffExampleUIThread.f2(int):void, 0, [Updated Cost of f2 is 5 + 5 ⋅ x (degree is 1),{x},Loop at line 27]

@ -1,2 +1 @@
INFINITE_EXECUTION_TIME, 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, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f7(int):void, 0, [Call to void DiffExampleColdStart.f1(int),Unbounded loop,Loop at line 26]

@ -1,65 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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:
// 1 bottom (zero), 2 constant, 1 linear, 1 top
// constructor: constant
// f1: top
// f2: bottom (zero)
// f3: constant
// f4: linear
// f5: n log n
// f6: n log n
// f7: top by call to f1
public class DiffExampleColdStart {
// cost: top
private static void f1(int k) {
int i = 0;
while (i >=0) {
i++;
}
}
// cost: bottom (0)
private static void f2(int k) {}
// cost: constant (5)
private static int f3() {
int i, j;
i = 17;
j = 31;
return i + j + 3 + 7;
}
// cost: linear
private static int f4(int k) {
for (int i = 0; i < k; i++) {
int [] a = new int[100];
}
return 0;
}
// cost: n log n
private void f5(ArrayList<Integer> list) {
java.util.Collections.sort(list);
}
// cost: n log n
private void f6(ArrayList<Integer> list) {
f5(list);
}
// cost: top by call to f1
private static void f7(int k) {
f1(k);
}
}

@ -1,56 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This class has the following costs:
// 2 constant, 1 linear, 1 quadratic
// constructor: constant
// f1: linear
// f2: quadratic
// f4: constant
// f5: linear
// f6: quadratic
// f7: top
public class DiffExampleColdStart {
// cost: linear
private static int f1(int k) {
for (int i = 0; i < k; i++) {
}
return 0;
}
// cost: quadratic
private static void f2(int k) {
for (int i = 0; i < k; i++) {
f1(k);
}
}
// cost: constant
private static int f4(int k) {
int i = 1;
return i + k;
}
// cost: linear
private static void f5(int n) {
f1(n);
}
// cost: quadratic
private static void f6(int n) {
f2(n);
}
// cost: top
private static void f7(int k) {
int i = 0;
while (i >=0) {
i++;
}
}
}
Loading…
Cancel
Save