1fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes/* 2fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * Copyright (C) 2013 Google Inc. 3fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * 4fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 5fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * you may not use this file except in compliance with the License. 6fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * You may obtain a copy of the License at 7fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * 8fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 9fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * 10fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * Unless required by applicable law or agreed to in writing, software 11fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 12fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * See the License for the specific language governing permissions and 14fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes * limitations under the License. 15fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes */ 16fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 17fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughespackage benchmarks.regression; 18fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 1912fbbc16959d078dde23b3b15c8d3d127ef33507Neil Fullerimport android.icu.util.TimeZone; 20ea13f8291a92b6f47f50011da1d5e8c107984bc3Paul Duffinimport android.icu.util.ULocale; 21a40d2447b6f516116135ee7f126579771ba98a2cNeil Fullerimport libcore.icu.DateIntervalFormat; 22a40d2447b6f516116135ee7f126579771ba98a2cNeil Fuller 23a40d2447b6f516116135ee7f126579771ba98a2cNeil Fullerimport static libcore.icu.DateUtilsBridge.*; 24fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 25ea13f8291a92b6f47f50011da1d5e8c107984bc3Paul Duffinpublic class DateIntervalFormatBenchmark { 26fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes public void timeDateIntervalFormat_formatDateRange_DATE(int reps) throws Exception { 2712fbbc16959d078dde23b3b15c8d3d127ef33507Neil Fuller ULocale l = ULocale.US; 28fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes TimeZone utc = TimeZone.getTimeZone("UTC"); 29fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_WEEKDAY; 30fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 31fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes for (int rep = 0; rep < reps; ++rep) { 32a40d2447b6f516116135ee7f126579771ba98a2cNeil Fuller DateIntervalFormat.formatDateRange(l, utc, 0L, 0L, flags); 33fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 34fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 35fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 36fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes public void timeDateIntervalFormat_formatDateRange_TIME(int reps) throws Exception { 3712fbbc16959d078dde23b3b15c8d3d127ef33507Neil Fuller ULocale l = ULocale.US; 38fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes TimeZone utc = TimeZone.getTimeZone("UTC"); 39fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes int flags = FORMAT_SHOW_TIME | FORMAT_24HOUR; 40fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 41fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes for (int rep = 0; rep < reps; ++rep) { 42a40d2447b6f516116135ee7f126579771ba98a2cNeil Fuller DateIntervalFormat.formatDateRange(l, utc, 0L, 0L, flags); 43fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 44fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 45fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 46fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes public void timeDateIntervalFormat_formatDateRange_DATE_TIME(int reps) throws Exception { 4712fbbc16959d078dde23b3b15c8d3d127ef33507Neil Fuller ULocale l = ULocale.US; 48fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes TimeZone utc = TimeZone.getTimeZone("UTC"); 49fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_WEEKDAY | FORMAT_SHOW_TIME | FORMAT_24HOUR; 50fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 51fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes for (int rep = 0; rep < reps; ++rep) { 52a40d2447b6f516116135ee7f126579771ba98a2cNeil Fuller DateIntervalFormat.formatDateRange(l, utc, 0L, 0L, flags); 53fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 54fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 55fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes} 56