diff --git a/infer/src/Makefile b/infer/src/Makefile index 5b19d5e80..0f8bcf4b5 100644 --- a/infer/src/Makefile +++ b/infer/src/Makefile @@ -19,7 +19,7 @@ INFER_MAIN = infer #### Checkers declarations #### -INFER_ATDGEN_STUB_BASES = atd/jsonbug atd/runstate atd/stacktree atd/java_method_decl +INFER_ATDGEN_STUB_BASES = atd/jsonbug atd/runstate atd/stacktree atd/java_method_decl atd/perf_profiler INFER_ATDGEN_TYPES = j t INFER_ATDGEN_STUB_ATDS = $(INFER_ATDGEN_STUB_BASES:.atd) INFER_ATDGEN_SUFFIXES = $(foreach atd_t,$(INFER_ATDGEN_TYPES),_$(atd_t).ml _$(atd_t).mli) diff --git a/infer/src/atd/perf_profiler.atd b/infer/src/atd/perf_profiler.atd new file mode 100644 index 000000000..793fd5f7a --- /dev/null +++ b/infer/src/atd/perf_profiler.atd @@ -0,0 +1,7 @@ +type perf_profiler_item = { + function_name : string; + avg_inclusive_cpu_time_ms : float; + avg_exclusive_cpu_time_ms : float; +} + +type perf_profiler = perf_profiler_item list \ No newline at end of file diff --git a/infer/src/unit/PerfProfilerATDParserTest.ml b/infer/src/unit/PerfProfilerATDParserTest.ml new file mode 100644 index 000000000..0dca17d88 --- /dev/null +++ b/infer/src/unit/PerfProfilerATDParserTest.ml @@ -0,0 +1,26 @@ +(* + * Copyright (c) 2018-present, Facebook, Inc. + * + * 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>","avg_inclusive_cpu_time_ms":123.01234567899,"avg_exclusive_cpu_time_ms":9.8765432123456}]|} + , [ { Perf_profiler_t.function_name= "pkg/cls::" + ; avg_inclusive_cpu_time_ms= 123.01234567899 + ; 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 diff --git a/infer/src/unit/inferunit.ml b/infer/src/unit/inferunit.ml index 6f085d88c..96e3521f9 100644 --- a/infer/src/unit/inferunit.ml +++ b/infer/src/unit/inferunit.ml @@ -35,6 +35,7 @@ let () = ; DifferentialFiltersTests.tests ; FileDiffTests.tests ; JavaProfilerSamplesTest.tests + ; PerfProfilerATDParserTest.tests ; ProcCfgTests.tests ; LivenessTests.tests ; SchedulerTests.tests