blob: c3eb6d3fbac0416511f14f0310f25319c12994d6 [file] [log] [blame]
Colin Crossbd3efbc2013-11-15 17:49:47 -08001#
2# Copyright (C) 2013 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
Colin Crossbd3efbc2013-11-15 17:49:47 -080017LOCAL_PATH := $(call my-dir)
18
19# -----------------------------------------------------------------------------
Colin Cross7b9df192013-11-15 14:34:22 -080020# Benchmarks library, usable by projects outside this directory.
21# -----------------------------------------------------------------------------
22
23include $(CLEAR_VARS)
24LOCAL_MODULE := libbenchmark
25LOCAL_CFLAGS += -O2 -Wall -Wextra -Werror
26LOCAL_SRC_FILES := benchmark_main.cpp
27LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
28LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
29include $(BUILD_STATIC_LIBRARY)
30
Christopher Ferris941a1a12015-01-26 16:54:40 -080031# Only supported on linux systems.
32ifeq ($(HOST_OS),linux)
33
Colin Cross7b9df192013-11-15 14:34:22 -080034include $(CLEAR_VARS)
35LOCAL_MODULE := libbenchmark
36LOCAL_CFLAGS += -O2 -Wall -Wextra -Werror
37LOCAL_SRC_FILES := benchmark_main.cpp
38LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
39LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
40LOCAL_MULTILIB := both
41include $(BUILD_HOST_STATIC_LIBRARY)
42
Christopher Ferris941a1a12015-01-26 16:54:40 -080043endif
44
Colin Cross7b9df192013-11-15 14:34:22 -080045# -----------------------------------------------------------------------------
Colin Crossbd3efbc2013-11-15 17:49:47 -080046# Benchmarks.
47# -----------------------------------------------------------------------------
48
49benchmark_c_flags = \
50 -O2 \
Elliott Hughesd2867962014-06-03 15:22:34 -070051 -Wall -Wextra -Wunused \
Colin Crossbd3efbc2013-11-15 17:49:47 -080052 -Werror \
53 -fno-builtin \
Serban Constantinescu282e2322013-10-22 11:30:12 +010054 -std=gnu++11 \
Colin Crossbd3efbc2013-11-15 17:49:47 -080055
56benchmark_src_files = \
Colin Crossbd3efbc2013-11-15 17:49:47 -080057 math_benchmark.cpp \
Elliott Hughesb28e4902014-03-11 11:19:06 -070058 pthread_benchmark.cpp \
59 semaphore_benchmark.cpp \
60 stdio_benchmark.cpp \
Colin Crossbd3efbc2013-11-15 17:49:47 -080061 string_benchmark.cpp \
62 time_benchmark.cpp \
Elliott Hughesb28e4902014-03-11 11:19:06 -070063 unistd_benchmark.cpp \
Colin Crossbd3efbc2013-11-15 17:49:47 -080064
65# Build benchmarks for the device (with bionic's .so). Run with:
Elliott Hughes212e0e32014-12-01 16:43:51 -080066# adb shell bionic-benchmarks32
67# adb shell bionic-benchmarks64
Colin Crossbd3efbc2013-11-15 17:49:47 -080068include $(CLEAR_VARS)
69LOCAL_MODULE := bionic-benchmarks
Christopher Ferris345b49a2014-04-22 10:42:12 -070070LOCAL_MODULE_STEM_32 := bionic-benchmarks32
71LOCAL_MODULE_STEM_64 := bionic-benchmarks64
72LOCAL_MULTILIB := both
Colin Crossbd3efbc2013-11-15 17:49:47 -080073LOCAL_CFLAGS += $(benchmark_c_flags)
Elliott Hughes212e0e32014-12-01 16:43:51 -080074LOCAL_SRC_FILES := $(benchmark_src_files) property_benchmark.cpp
Colin Cross7b9df192013-11-15 14:34:22 -080075LOCAL_STATIC_LIBRARIES += libbenchmark
Colin Crossbd3efbc2013-11-15 17:49:47 -080076include $(BUILD_EXECUTABLE)
77
Elliott Hughes212e0e32014-12-01 16:43:51 -080078# We don't build a static benchmark executable because it's not usually
79# useful. If you're trying to run the current benchmarks on an older
80# release, it's (so far at least) always because you want to measure the
81# performance of the old release's libc, and a static benchmark isn't
82# going to let you do that.
83
Christopher Ferris941a1a12015-01-26 16:54:40 -080084# Only supported on linux systems.
85ifeq ($(HOST_OS),linux)
86
Elliott Hughes212e0e32014-12-01 16:43:51 -080087# Build benchmarks for the host (against glibc!). Run with:
88include $(CLEAR_VARS)
89LOCAL_MODULE := bionic-benchmarks-glibc
90LOCAL_MODULE_STEM_32 := bionic-benchmarks-glibc32
91LOCAL_MODULE_STEM_64 := bionic-benchmarks-glibc64
92LOCAL_MULTILIB := both
Elliott Hughes212e0e32014-12-01 16:43:51 -080093LOCAL_CFLAGS += $(benchmark_c_flags)
94LOCAL_LDFLAGS += -lrt
95LOCAL_SRC_FILES := $(benchmark_src_files)
Colin Cross7b9df192013-11-15 14:34:22 -080096LOCAL_STATIC_LIBRARIES += libbenchmark
Elliott Hughes212e0e32014-12-01 16:43:51 -080097include $(BUILD_HOST_EXECUTABLE)
98
Christopher Ferris941a1a12015-01-26 16:54:40 -080099endif
100
Elliott Hughes625993d2014-07-15 16:53:13 -0700101ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
Dmitriy Ivanov06b1b8c2014-12-02 14:00:13 -0800102include $(LOCAL_PATH)/../build/run-on-host.mk
Christopher Ferris3347a792014-05-01 13:44:57 -0700103
Dmitriy Ivanov06b1b8c2014-12-02 14:00:13 -0800104ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
105bionic-benchmarks-run-on-host32: bionic-benchmarks bionic-prepare-run-on-host
Christopher Ferris3347a792014-05-01 13:44:57 -0700106 ANDROID_DATA=$(TARGET_OUT_DATA) \
107 ANDROID_ROOT=$(TARGET_OUT) \
Dmitriy Ivanov06b1b8c2014-12-02 14:00:13 -0800108 $(TARGET_OUT_EXECUTABLES)/bionic-benchmarks32 $(BIONIC_BENCHMARKS_FLAGS)
109endif
110
111ifeq ($(TARGET_IS_64_BIT),true)
112bionic-benchmarks-run-on-host64: bionic-benchmarks bionic-prepare-run-on-host
113 ANDROID_DATA=$(TARGET_OUT_DATA) \
114 ANDROID_ROOT=$(TARGET_OUT) \
115 $(TARGET_OUT_EXECUTABLES)/bionic-benchmarks64 $(BIONIC_BENCHMARKS_FLAGS)
116endif
117
118endif