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