Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2ad8c60 authored by Snehal N Bhamare's avatar Snehal N Bhamare
Browse files

Benchmark: Remove libutils dependency

Test: extractorTest -P /data/local/tmp/MediaBenchmark/res/

Bug: 142464243

Change-Id: Id109b6cf492a65dd7a7875dbba9b7f3422ff94ff
parent 835742ef
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ cc_library_static {
    srcs: [
    srcs: [
        "BenchmarkCommon.cpp",
        "BenchmarkCommon.cpp",
        "Stats.cpp",
        "Stats.cpp",
        "utils/Timers.cpp",
    ],
    ],


    export_include_dirs: ["."],
    export_include_dirs: ["."],
@@ -49,7 +50,6 @@ cc_defaults {
    shared_libs: [
    shared_libs: [
        "libmediandk",
        "libmediandk",
        "liblog",
        "liblog",
        "libutils",
    ],
    ],


    cflags: [
    cflags: [
+0 −2
Original line number Original line Diff line number Diff line
@@ -17,8 +17,6 @@
#ifndef __BENCHMARK_COMMON_H__
#ifndef __BENCHMARK_COMMON_H__
#define __BENCHMARK_COMMON_H__
#define __BENCHMARK_COMMON_H__


#include <utils/Log.h>

#include <inttypes.h>
#include <inttypes.h>
#include <mutex>
#include <mutex>
#include <queue>
#include <queue>
+0 −1
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@


#include <iostream>
#include <iostream>
#include <stdint.h>
#include <stdint.h>
#include <utils/Log.h>


#include "Stats.h"
#include "Stats.h"


+18 −1
Original line number Original line Diff line number Diff line
@@ -17,11 +17,28 @@
#ifndef __STATS_H__
#ifndef __STATS_H__
#define __STATS_H__
#define __STATS_H__


#include <android/log.h>

#ifndef ALOG
#define ALOG(priority, tag, ...) ((void)__android_log_print(ANDROID_##priority, tag, __VA_ARGS__))

#define ALOGI(...) ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)
#define ALOGE(...) ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define ALOGD(...) ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#if LOG_NDEBUG
#define ALOGV(cond, ...)   ((void)0)
#else
#define ALOGV(...) ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
#endif
#endif  // ALOG

#include <sys/time.h>
#include <sys/time.h>
#include <algorithm>
#include <algorithm>
#include <numeric>
#include <numeric>
#include <vector>
#include <vector>
#include <utils/Timers.h>

// Include local copy of Timers taken from system/core/libutils
#include "utils/Timers.h"


using namespace std;
using namespace std;


+62 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2005 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//
// Timer functions.
//

#define LOG_TAG "Timers"

#include <limits.h>
#include <time.h>

#include "Timers.h"

#if defined(__ANDROID__)
nsecs_t systemTime(int clock) {
    static const clockid_t clocks[] = {CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID,
                                       CLOCK_THREAD_CPUTIME_ID, CLOCK_BOOTTIME};
    struct timespec t;
    t.tv_sec = t.tv_nsec = 0;
    clock_gettime(clocks[clock], &t);
    return nsecs_t(t.tv_sec) * 1000000000LL + t.tv_nsec;
}
#else
nsecs_t systemTime(int /*clock*/) {
    // Clock support varies widely across hosts. Mac OS doesn't support
    // posix clocks, older glibcs don't support CLOCK_BOOTTIME and Windows
    // is windows.
    struct timeval t;
    t.tv_sec = t.tv_usec = 0;
    gettimeofday(&t, NULL);
    return nsecs_t(t.tv_sec) * 1000000000LL + nsecs_t(t.tv_usec) * 1000LL;
}
#endif

int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime) {
    nsecs_t timeoutDelayMillis;
    if (timeoutTime > referenceTime) {
        uint64_t timeoutDelay = uint64_t(timeoutTime - referenceTime);
        if (timeoutDelay > uint64_t((INT_MAX - 1) * 1000000LL)) {
            timeoutDelayMillis = -1;
        } else {
            timeoutDelayMillis = (timeoutDelay + 999999LL) / 1000000LL;
        }
    } else {
        timeoutDelayMillis = 0;
    }
    return (int)timeoutDelayMillis;
}
Loading