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