summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-03-11 11:17:30 -0700
committerElliott Hughes <enh@google.com>2014-03-11 11:17:30 -0700
commitea6b3d6967f516c47d2e453c6f4a5fb3e69fbbf6 (patch)
treec69da5b49eac1d758c3d3623f157c09659196dd6
parentfe9aee4780d561b6d3990094f74168bc9560fd8b (diff)
downloadextras-ea6b3d6967f516c47d2e453c6f4a5fb3e69fbbf6.tar.gz
Remove obsolete benchmarks.
bionic now has all of these. Change-Id: I0b65f019b88bc9ac7d33bd424361497320c66b7b
-rw-r--r--tests/bionic/libc/Android.mk28
-rw-r--r--tests/bionic/libc/common/bench_pthread.c202
-rw-r--r--tests/bionic/libc/common/bench_stdio.c117
3 files changed, 0 insertions, 347 deletions
diff --git a/tests/bionic/libc/Android.mk b/tests/bionic/libc/Android.mk
index 6b1d427e..e37d4b24 100644
--- a/tests/bionic/libc/Android.mk
+++ b/tests/bionic/libc/Android.mk
@@ -61,7 +61,6 @@ endef
# First, the tests in 'common'
sources := \
- common/bench_stdio.c \
common/test_clock.c \
common/test_cpu_set.c \
common/test_executable_destructor.c \
@@ -226,31 +225,4 @@ sources := \
EXTRA_CFLAGS := -mandroid
#$(call device-test, $(sources))
-# NOTE: We build both a shared and static version of bench_pthread.
-# the shared version will use the target device's C library, while
-# the static one will use the current build product implementation.
-# This is ideal to quantify pthread optimizations.
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := common/bench_pthread.c
-LOCAL_MODULE := bench_pthread_shared
-LOCAL_MODULE_TAGS := tests
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := common/bench_pthread.c
-LOCAL_MODULE := bench_pthread_static
-LOCAL_MODULE_TAGS := tests
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_STATIC_LIBRARIES := libc
-include $(BUILD_EXECUTABLE)
-
-ifeq ($(HOST_OS),linux)
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := common/bench_pthread.c
-LOCAL_MODULE := bench_pthread
-LOCAL_LDLIBS += -lpthread -lrt
-LOCAL_MODULE_TAGS := tests
-include $(BUILD_HOST_EXECUTABLE)
-endif
-
endif # BIONIC_TESTS
diff --git a/tests/bionic/libc/common/bench_pthread.c b/tests/bionic/libc/common/bench_pthread.c
deleted file mode 100644
index 4e46f61b..00000000
--- a/tests/bionic/libc/common/bench_pthread.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* This program is used to benchmark various pthread operations
- * Note that we want to be able to build it with GLibc, both on
- * a Linux host and an Android device. For example, on ARM, one
- * can build it manually with:
- *
- * arm-linux-none-gnueabi-gcc -static -o bench_pthread_gnueabi \
- * bench_pthread.c -O2 -lpthread -lrt
- */
-#define _GNU_SOURCE 1
-#include <time.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <limits.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#define S(x) S_(x)
-#define S_(x) #x
-
-#define C(x,y) C_(x,y)
-#define C_(x,y) x ## y
-
-#ifndef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER
-#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
-#endif
-
-#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER
-#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-#endif
-
-static int64_t now_ns(void)
-{
- struct timespec ts;
- /* NOTE: get thread-specific CPU-time clock to ensure
- * we don't measure stuff like kernel thread preemptions
- * that might happen during the benchmark
- */
- clock_gettime(CLOCK_THREAD_CPUTIME_ID,&ts);
- return ts.tv_sec*1000000000LL + ts.tv_nsec;
-}
-
-#define SUBCOUNT 10000
-#define MAX_STATS 1000000
-
-/* Maximum time we'll wait for a single bench run */
-#define MAX_WAIT_MS 1000
-
-static int64_t stats[MAX_STATS];
-
-static int
-compare_stats(const void* a, const void* b)
-{
- uint64_t sa = *(const uint64_t*)a;
- uint64_t sb = *(const uint64_t*)b;
- if (sa < sb)
- return -1;
- if (sa > sb)
- return +1;
- else
- return 0;
-}
-
-static void
-filter_stats(int count, const char* statement)
-{
- int64_t min, max, avg, median;
-
- /* sort the array in increasing order */
- qsort(stats, count, sizeof(stats[0]), compare_stats);
-
- /* trim 10% to remove outliers */
- int min_index = count*0.05;
- int max_index = count - min_index;
- if (max_index >= count)
- max_index = count-1;
-
- count = (max_index - min_index)+1;
-
- /* the median is the center item */
- median = stats[(min_index+max_index)/2];
-
- /* the minimum is the first, the max the last */
- min = stats[min_index];
- max = stats[max_index];
-
- /* compute the average */
- int nn;
- int64_t total = 0;
- for (nn = min_index; nn <= max_index; nn++) {
- total += stats[nn];
- }
-
- printf("BENCH: %5.1f %5.1f %5.1f, %s\n",
- min*1./SUBCOUNT,
- max*1./SUBCOUNT,
- median*1./SUBCOUNT,
- statement);
- if (0) {
- for (nn = min_index; nn <= max_index; nn++) {
- printf(" %lld", (long long)stats[nn]);
- }
- printf("\n");
- }
-}
-
-#define BENCH_COUNT(stmnt,total) do { \
- int64_t count = total; \
- int num_stats = 0; \
- int64_t bench_start = now_ns(); \
- while (num_stats < MAX_STATS && count >= SUBCOUNT) { \
- int tries = SUBCOUNT; \
- int64_t sub_start = now_ns(); \
- count -= tries; \
- for ( ; tries > 0; tries-- ) {\
- stmnt;\
- }\
- int64_t sub_end = now_ns(); \
- stats[num_stats++] = sub_end - sub_start; \
- if (sub_end - bench_start >= MAX_WAIT_MS*1e6) \
- break; \
- } \
- filter_stats(num_stats, #stmnt); \
- } while (0)
-
-#define DEFAULT_COUNT 10000000
-
-#define BENCH(stmnt) BENCH_COUNT(stmnt,DEFAULT_COUNT)
-
-/* Will be called by pthread_once() for benchmarking */
-static void _dummy_init(void)
-{
- /* nothing */
-}
-
-/* Used when creating the key */
-static void key_destroy(void* param)
-{
- /* nothing */
-}
-
-int main(void)
-{
- pthread_once_t once = PTHREAD_ONCE_INIT;
- pthread_once(&once, _dummy_init);
-
- pthread_key_t key;
- pthread_key_create(&key, key_destroy);
- pthread_setspecific(key, (void*)(int)100);
-
- BENCH(getpid());
- BENCH(pthread_self());
- BENCH(pthread_getspecific(key));
- BENCH(pthread_once(&once, _dummy_init));
-
- pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
- BENCH(pthread_mutex_lock(&mutex); pthread_mutex_unlock(&mutex));
-
- pthread_mutex_t errorcheck_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER;
- BENCH(pthread_mutex_lock(&errorcheck_mutex); pthread_mutex_unlock(&errorcheck_mutex));
-
- pthread_mutex_t recursive_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
- BENCH(pthread_mutex_lock(&recursive_mutex); pthread_mutex_unlock(&recursive_mutex));
-
- /* TODO: Benchmark pshared mutexes */
-
- sem_t semaphore;
- int dummy;
- sem_init(&semaphore, 1, 1);
- BENCH(sem_getvalue(&semaphore,&dummy));
- BENCH(sem_wait(&semaphore); sem_post(&semaphore));
- return 0;
-}
diff --git a/tests/bionic/libc/common/bench_stdio.c b/tests/bionic/libc/common/bench_stdio.c
deleted file mode 100644
index 4c19bf1e..00000000
--- a/tests/bionic/libc/common/bench_stdio.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* This program tries to benchmark stdio operations like fread() and
- * fwrite() with various chunk sizes. We always read/write from /dev/zero
- * to ensure that disk speed and caching don't change our results.
- *
- * We really do this to measure improvements in the low-level stdio
- * features.
- */
-
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-
-static char buffer[1024*1024];
-
-/* Return current time in milli-seconds, as a double */
-static double
-now_ms(void)
-{
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts.tv_sec*1000. + ts.tv_nsec*1e-6;
-}
-
-void read_file(FILE* fp, int chunkSize)
-{
- int totalSize = sizeof(buffer);
- for ( ; totalSize > 0; totalSize -= chunkSize) {
- fread(buffer, 1, chunkSize, fp);
- }
-}
-
-void write_file(FILE* fp, int chunkSize)
-{
- int totalSize = sizeof(buffer);
- for ( ; totalSize > 0; totalSize -= chunkSize) {
- fwrite(buffer, 1, chunkSize, fp);
- }
-}
-
-#define BENCH(op,...) \
- do { \
- double time_ms = now_ms(); \
- op ; \
- time_ms = now_ms() - time_ms; \
- double bandwidth = sizeof(buffer)*1000./1024./time_ms; \
- printf("bench %-30s %8.2f ms (%.1f KB/s) \n", #op, time_ms, bandwidth ); \
- } while (0)
-
-int main(void)
-{
- FILE* fp = fopen("/dev/zero", "rw");
-
- if (fp == NULL) {
- fprintf(stderr,"Could not open /dev/zero: %s\n", strerror(errno));
- return 1;
- }
-
- BENCH(read_file(fp,1));
- BENCH(read_file(fp,2));
- BENCH(read_file(fp,3));
- BENCH(read_file(fp,4));
- BENCH(read_file(fp,8));
- BENCH(read_file(fp,16));
- BENCH(read_file(fp,32));
- BENCH(read_file(fp,64));
- BENCH(read_file(fp,256));
- BENCH(read_file(fp,1024));
- BENCH(read_file(fp,4096));
- BENCH(read_file(fp,16384));
- BENCH(read_file(fp,65536));
-
- BENCH(write_file(fp,1));
- BENCH(write_file(fp,2));
- BENCH(write_file(fp,3));
- BENCH(write_file(fp,4));
- BENCH(write_file(fp,8));
- BENCH(write_file(fp,16));
- BENCH(write_file(fp,32));
- BENCH(write_file(fp,64));
- BENCH(write_file(fp,256));
- BENCH(write_file(fp,1024));
- BENCH(write_file(fp,4096));
- BENCH(write_file(fp,16384));
- BENCH(write_file(fp,65536));
-
- fclose(fp);
- return 0;
-}