• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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 import java.util.TimeZone;
21 
22 public class TimeZoneBenchmark extends SimpleBenchmark {
timeTimeZone_getDefault(int reps)23     public void timeTimeZone_getDefault(int reps) throws Exception {
24         for (int rep = 0; rep < reps; ++rep) {
25             TimeZone.getDefault();
26         }
27     }
28 
timeTimeZone_getTimeZoneUTC(int reps)29     public void timeTimeZone_getTimeZoneUTC(int reps) throws Exception {
30         for (int rep = 0; rep < reps; ++rep) {
31             TimeZone.getTimeZone("UTC");
32         }
33     }
34 
timeTimeZone_getTimeZone_default(int reps)35     public void timeTimeZone_getTimeZone_default(int reps) throws Exception {
36         String defaultId = TimeZone.getDefault().getID();
37         for (int rep = 0; rep < reps; ++rep) {
38             TimeZone.getTimeZone(defaultId);
39         }
40     }
41 
42     // A time zone with relatively few transitions.
timeTimeZone_getTimeZone_America_Caracas(int reps)43     public void timeTimeZone_getTimeZone_America_Caracas(int reps) throws Exception {
44         for (int rep = 0; rep < reps; ++rep) {
45             TimeZone.getTimeZone("America/Caracas");
46         }
47     }
48 
49     // A time zone with a lot of transitions.
timeTimeZone_getTimeZone_America_Santiago(int reps)50     public void timeTimeZone_getTimeZone_America_Santiago(int reps) throws Exception {
51         for (int rep = 0; rep < reps; ++rep) {
52             TimeZone.getTimeZone("America/Santiago");
53         }
54     }
55 
timeTimeZone_getTimeZone_GMT_plus_10(int reps)56     public void timeTimeZone_getTimeZone_GMT_plus_10(int reps) throws Exception {
57         for (int rep = 0; rep < reps; ++rep) {
58             TimeZone.getTimeZone("GMT+10");
59         }
60     }
61 }
62