diff --git a/Makefile b/Makefile index f1919be37..34ab77a0d 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ BUILD_SYSTEMS_TESTS += \ DIRECT_TESTS += \ java_checkers java_eradicate java_infer java_lab java_tracing java_quandary \ - java_racerd java_stability java_crashcontext java_starvation + java_racerd java_stability java_crashcontext java_starvation java_performance ifneq ($(ANT),no) BUILD_SYSTEMS_TESTS += ant endif diff --git a/infer/tests/codetoanalyze/java/performance/ArrayCost.java b/infer/tests/codetoanalyze/java/performance/ArrayCost.java new file mode 100644 index 000000000..5f5383cfc --- /dev/null +++ b/infer/tests/codetoanalyze/java/performance/ArrayCost.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +public class ArrayCost { + + private void ArrayCost_FP(int signum, int[] mag) { + if (mag.length > 0) { + + int i = 0; + + while (i < mag.length && mag[i] == 0) { + i++; + } + + } + } +} diff --git a/infer/tests/codetoanalyze/java/performance/Makefile b/infer/tests/codetoanalyze/java/performance/Makefile new file mode 100644 index 000000000..8e0a76d33 --- /dev/null +++ b/infer/tests/codetoanalyze/java/performance/Makefile @@ -0,0 +1,15 @@ +# Copyright (c) 2018 - present Facebook, Inc. +# All rights reserved. +# +# This source code is licensed under the BSD style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. + +TESTS_DIR = ../../.. + +ANALYZER = checkers +INFER_OPTIONS = --cost-only --debug-exceptions +INFERPRINT_OPTIONS = --issues-tests +SOURCES = $(wildcard *.java) + +include $(TESTS_DIR)/javac.make diff --git a/infer/tests/codetoanalyze/java/performance/issues.exp b/infer/tests/codetoanalyze/java/performance/issues.exp new file mode 100644 index 000000000..7b6823da8 --- /dev/null +++ b/infer/tests/codetoanalyze/java/performance/issues.exp @@ -0,0 +1 @@ +codetoanalyze/java/performance/ArrayCost.java, void ArrayCost.ArrayCost_FP(int,int[]), 0, INFINITE_EXECUTION_TIME_CALL, ERROR, []