1bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross#
2bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# Copyright (C) 2013 The Android Open Source Project
3bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross#
4bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# Licensed under the Apache License, Version 2.0 (the "License");
5bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# you may not use this file except in compliance with the License.
6bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# You may obtain a copy of the License at
7bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross#
8bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross#      http://www.apache.org/licenses/LICENSE-2.0
9bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross#
10bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# Unless required by applicable law or agreed to in writing, software
11bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# distributed under the License is distributed on an "AS IS" BASIS,
12bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# See the License for the specific language governing permissions and
14bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# limitations under the License.
15bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross#
16bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross
17bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Crossifneq ($(BUILD_TINY_ANDROID), true)
18bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross
19bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin CrossLOCAL_PATH := $(call my-dir)
20bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross
21bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# -----------------------------------------------------------------------------
22bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# Benchmarks.
23bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# -----------------------------------------------------------------------------
24bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross
25bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Crossbenchmark_c_flags = \
26bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross    -O2 \
27d286796fce1e6fff407b719a53eb2afbeb96c327Elliott Hughes    -Wall -Wextra -Wunused \
28bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross    -Werror \
29bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross    -fno-builtin \
30282e232e2a32cca8a288e81edddfd95f450cfc79Serban Constantinescu    -std=gnu++11 \
31bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross
32bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Crossbenchmark_src_files = \
33bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross    benchmark_main.cpp \
34bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross    math_benchmark.cpp \
35bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross    property_benchmark.cpp \
36b28e490b7350b21c5ae9e5b3bb3e082d8357a1b0Elliott Hughes    pthread_benchmark.cpp \
37b28e490b7350b21c5ae9e5b3bb3e082d8357a1b0Elliott Hughes    semaphore_benchmark.cpp \
38b28e490b7350b21c5ae9e5b3bb3e082d8357a1b0Elliott Hughes    stdio_benchmark.cpp \
39bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross    string_benchmark.cpp \
40bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross    time_benchmark.cpp \
41b28e490b7350b21c5ae9e5b3bb3e082d8357a1b0Elliott Hughes    unistd_benchmark.cpp \
42bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross
43bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross# Build benchmarks for the device (with bionic's .so). Run with:
44bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross#   adb shell bionic-benchmarks
45bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Crossinclude $(CLEAR_VARS)
46bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin CrossLOCAL_MODULE := bionic-benchmarks
47345b49a7c07fde18e9397ffba9079ff81a4c3d74Christopher FerrisLOCAL_MODULE_STEM_32 := bionic-benchmarks32
48345b49a7c07fde18e9397ffba9079ff81a4c3d74Christopher FerrisLOCAL_MODULE_STEM_64 := bionic-benchmarks64
49345b49a7c07fde18e9397ffba9079ff81a4c3d74Christopher FerrisLOCAL_MULTILIB := both
50bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin CrossLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
51bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin CrossLOCAL_CFLAGS += $(benchmark_c_flags)
527a39094465bbd01a22565fce1f1155c762f8d145Dan AlbertLOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
537a39094465bbd01a22565fce1f1155c762f8d145Dan AlbertLOCAL_SHARED_LIBRARIES += libstlport
54bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin CrossLOCAL_SRC_FILES := $(benchmark_src_files)
55bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Crossinclude $(BUILD_EXECUTABLE)
56bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Cross
573002131da33401cf1b45abbdbec58b7c751fc43aElliott Hughesifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
583347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferrisifeq ($(TARGET_ARCH),x86)
593347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher FerrisLINKER = linker
603347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher FerrisNATIVE_SUFFIX=32
613347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferriselse
623347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher FerrisLINKER = linker64
633347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher FerrisNATIVE_SUFFIX=64
643347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferrisendif
653347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris
663347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferrisbionic-benchmarks-run-on-host: bionic-benchmarks $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
673347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	if [ ! -d /system -o ! -d /system/bin ]; then \
683347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	  echo "Attempting to create /system/bin"; \
693347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	  sudo mkdir -p -m 0777 /system/bin; \
703347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	fi
713347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	mkdir -p $(TARGET_OUT_DATA)/local/tmp
723347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
733347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
743347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	ANDROID_DATA=$(TARGET_OUT_DATA) \
753347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	ANDROID_ROOT=$(TARGET_OUT) \
763347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris	LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
773347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris		$(TARGET_OUT_EXECUTABLES)/bionic-benchmarks$(NATIVE_SUFFIX) $(BIONIC_BENCHMARKS_FLAGS)
783347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferrisendif # linux-x86
793347a7966413223fd7ba4aa80d5e5003f8e3ca15Christopher Ferris
80bd3efbc9b585e0c9801b0b35f282347cb8692ca8Colin Crossendif # !BUILD_TINY_ANDROID
81