Home | History | Annotate | Download | only in regression
      1 /*
      2  * Copyright (C) 2016 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.BeforeExperiment;
     20 
     21 import java.text.DateFormat;
     22 import java.util.Locale;
     23 
     24 public final class DateFormatBenchmark {
     25 
     26     private Locale locale1;
     27     private Locale locale2;
     28     private Locale locale3;
     29     private Locale locale4;
     30 
     31     @BeforeExperiment
     32     protected void setUp() throws Exception {
     33         locale1 = Locale.TAIWAN;
     34         locale2 = Locale.GERMANY;
     35         locale3 = Locale.FRANCE;
     36         locale4 = Locale.ITALY;
     37     }
     38 
     39     public void timeGetDateTimeInstance(int reps) throws Exception {
     40         for (int i = 0; i < reps; ++i) {
     41             DateFormat.getDateTimeInstance();
     42         }
     43     }
     44 
     45     public void timeGetDateTimeInstance_multiple(int reps) throws Exception {
     46         for (int i = 0; i < reps; ++i) {
     47             DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale1);
     48             DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale2);
     49             DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale3);
     50             DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale4);
     51         }
     52     }
     53 }
     54