Home | History | Annotate | Download | only in tests
      1 /*
      2  * Copyright (C) 2013 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 
     17 #include "benchmark.h"
     18 
     19 #include <time.h>
     20 
     21 #if defined(__BIONIC__)
     22 
     23 // Used by the horrible android.text.format.Time class, which is used by Calendar. http://b/8270865.
     24 extern "C" void localtime_tz(const time_t* const timep, struct tm* tmp, const char* tz);
     25 
     26 static void BM_time_localtime_tz(int iters) {
     27   StartBenchmarkTiming();
     28 
     29   time_t now(time(NULL));
     30   tm broken_down_time;
     31   for (int i = 0; i < iters; ++i) {
     32     localtime_tz(&now, &broken_down_time, "Europe/Berlin");
     33   }
     34 
     35   StopBenchmarkTiming();
     36 }
     37 BENCHMARK(BM_time_localtime_tz);
     38 #endif
     39