@Test public void testPerformance() { Set<String> allZones = ZoneId.getAvailableZoneIds(); List<String> zoneList = new ArrayList<>(allZones); Collections.sort(zoneList); List<ZoneId> zones = new ArrayList<>(zoneList.size()); List<TimeZoneRulesImpl> zoneRules = new ArrayList<>(zoneList.size()); for (String z : zoneList) { ZoneId zone = ZoneId.of(z); zones.add(zone); zoneRules.add(new TimeZoneRulesImpl(zone.getRules())); } long millis = Dates.toMillis(1900, 1, 1, 0, 0); long deadline = Dates.toMillis(2615, 12, 31, 0, 0); while (millis < deadline) { for (int i = 0, n = zones.size(); i < n; i++) { zoneRules.get(i).getOffset(millis); } millis += Dates.DAY_MILLIS; } }
@Override public long getOffset(long millis, int year, boolean leap) { if (standardOffset != Long.MIN_VALUE) { return standardOffset; } if (ruleCount > 0 && millis > cutoffTransition) { return fromRules(millis, year, leap); } if (millis > cutoffTransition) { return lastWall; } return fromHistory(millis); }
TimeZoneRulesImpl implements TimeZoneRules { @Override public long getOffset(long millis, int year, boolean leap) { if (standardOffset != Long.MIN_VALUE) { return standardOffset; } if (ruleCount > 0 && millis > cutoffTransition) { return fromRules(millis, year, leap); } if (millis > cutoffTransition) { return lastWall; } return fromHistory(millis); } }
TimeZoneRulesImpl implements TimeZoneRules { @Override public long getOffset(long millis, int year, boolean leap) { if (standardOffset != Long.MIN_VALUE) { return standardOffset; } if (ruleCount > 0 && millis > cutoffTransition) { return fromRules(millis, year, leap); } if (millis > cutoffTransition) { return lastWall; } return fromHistory(millis); } TimeZoneRulesImpl(ZoneRules rules); }
TimeZoneRulesImpl implements TimeZoneRules { @Override public long getOffset(long millis, int year, boolean leap) { if (standardOffset != Long.MIN_VALUE) { return standardOffset; } if (ruleCount > 0 && millis > cutoffTransition) { return fromRules(millis, year, leap); } if (millis > cutoffTransition) { return lastWall; } return fromHistory(millis); } TimeZoneRulesImpl(ZoneRules rules); @Override long getOffset(long millis, int year, boolean leap); @Override long getOffset(long millis); }
TimeZoneRulesImpl implements TimeZoneRules { @Override public long getOffset(long millis, int year, boolean leap) { if (standardOffset != Long.MIN_VALUE) { return standardOffset; } if (ruleCount > 0 && millis > cutoffTransition) { return fromRules(millis, year, leap); } if (millis > cutoffTransition) { return lastWall; } return fromHistory(millis); } TimeZoneRulesImpl(ZoneRules rules); @Override long getOffset(long millis, int year, boolean leap); @Override long getOffset(long millis); static final long SAVING_INSTANT_TRANSITION; static final long STANDARD_OFFSETS; static final long LAST_RULES; static final long SAVINGS_LOCAL_TRANSITION; static final long WALL_OFFSETS; }