1 /* 2 * Copyright (C) 2013 Google Inc. 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 package benchmarks.regression; 18 19 import com.google.caliper.SimpleBenchmark; 20 21 import android.icu.util.ULocale; 22 import android.icu.util.TimeZone; 23 24 import libcore.icu.DateIntervalFormat; 25 26 import static libcore.icu.DateUtilsBridge.*; 27 28 public class DateIntervalFormatBenchmark extends SimpleBenchmark { timeDateIntervalFormat_formatDateRange_DATE(int reps)29 public void timeDateIntervalFormat_formatDateRange_DATE(int reps) throws Exception { 30 ULocale l = ULocale.US; 31 TimeZone utc = TimeZone.getTimeZone("UTC"); 32 int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_WEEKDAY; 33 34 for (int rep = 0; rep < reps; ++rep) { 35 DateIntervalFormat.formatDateRange(l, utc, 0L, 0L, flags); 36 } 37 } 38 timeDateIntervalFormat_formatDateRange_TIME(int reps)39 public void timeDateIntervalFormat_formatDateRange_TIME(int reps) throws Exception { 40 ULocale l = ULocale.US; 41 TimeZone utc = TimeZone.getTimeZone("UTC"); 42 int flags = FORMAT_SHOW_TIME | FORMAT_24HOUR; 43 44 for (int rep = 0; rep < reps; ++rep) { 45 DateIntervalFormat.formatDateRange(l, utc, 0L, 0L, flags); 46 } 47 } 48 timeDateIntervalFormat_formatDateRange_DATE_TIME(int reps)49 public void timeDateIntervalFormat_formatDateRange_DATE_TIME(int reps) throws Exception { 50 ULocale l = ULocale.US; 51 TimeZone utc = TimeZone.getTimeZone("UTC"); 52 int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_WEEKDAY | FORMAT_SHOW_TIME | FORMAT_24HOUR; 53 54 for (int rep = 0; rep < reps; ++rep) { 55 DateIntervalFormat.formatDateRange(l, utc, 0L, 0L, flags); 56 } 57 } 58 } 59