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 19fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughesimport com.google.caliper.SimpleBenchmark; 20fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 21fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughesimport java.util.Locale; 22fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughesimport java.util.TimeZone; 23fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 24fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughesimport static libcore.icu.DateIntervalFormat.*; 25fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 26fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughespublic class DateIntervalFormatBenchmark extends SimpleBenchmark { 27fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes public void timeDateIntervalFormat_formatDateRange_DATE(int reps) throws Exception { 28fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes Locale l = Locale.US; 29fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes TimeZone utc = TimeZone.getTimeZone("UTC"); 30fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_WEEKDAY; 31fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 32fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes for (int rep = 0; rep < reps; ++rep) { 33fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes formatDateRange(l, utc, 0L, 0L, flags); 34fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 35fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 36fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 37fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes public void timeDateIntervalFormat_formatDateRange_TIME(int reps) throws Exception { 38fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes Locale l = Locale.US; 39fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes TimeZone utc = TimeZone.getTimeZone("UTC"); 40fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes int flags = FORMAT_SHOW_TIME | FORMAT_24HOUR; 41fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 42fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes for (int rep = 0; rep < reps; ++rep) { 43fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes formatDateRange(l, utc, 0L, 0L, flags); 44fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 45fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 46fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 47fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes public void timeDateIntervalFormat_formatDateRange_DATE_TIME(int reps) throws Exception { 48fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes Locale l = Locale.US; 49fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes TimeZone utc = TimeZone.getTimeZone("UTC"); 50fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_WEEKDAY | FORMAT_SHOW_TIME | FORMAT_24HOUR; 51fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes 52fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes for (int rep = 0; rep < reps; ++rep) { 53fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes formatDateRange(l, utc, 0L, 0L, flags); 54fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 55fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes } 56fd1d5e92b2eaf785cb18aa295b7b846cfc5e29afElliott Hughes} 57