1/*
2 * Copyright (C) 2016 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#include <benchmark/benchmark.h>
17
18#include <cutils/log.h>
19
20#include <unicode/uclean.h>
21#include <unicode/udata.h>
22
23#include <fcntl.h>
24#include <sys/stat.h>
25#include <sys/mman.h>
26
27int main(int argc, char** argv) {
28    const char* fn = "/system/usr/icu/" U_ICUDATA_NAME ".dat";
29    int fd = open(fn, O_RDONLY);
30    LOG_ALWAYS_FATAL_IF(fd == -1);
31    struct stat st;
32    LOG_ALWAYS_FATAL_IF(fstat(fd, &st) != 0);
33    void* data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
34
35    UErrorCode errorCode = U_ZERO_ERROR;
36    udata_setCommonData(data, &errorCode);
37    LOG_ALWAYS_FATAL_IF(U_FAILURE(errorCode));
38    u_init(&errorCode);
39    LOG_ALWAYS_FATAL_IF(U_FAILURE(errorCode));
40
41    benchmark::Initialize(&argc, argv);
42    benchmark::RunSpecifiedBenchmarks();
43
44    u_cleanup();
45    return 0;
46}
47