main.cpp 1.4 KB

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