@Test public void normalizeDuration_isCorrect() throws Exception { Assert.assertEquals("<=50", TimingUtils.normalizeDuration(49, TimingUtils.SECTION_DURATION_50_MS, TimingUtils.MAX_SECTION_20)); }
public static String normalizeDuration(long elapsedDuration, int sectionDurationMs, int maxSection) { long normalizedDuration; if (elapsedDuration % sectionDurationMs == 0) { normalizedDuration = elapsedDuration; } else { normalizedDuration = (elapsedDuration + sectionDurationMs) / sectionDurationMs * sectionDurationMs; } final int maxDuration = sectionDurationMs * maxSection; if (normalizedDuration <= maxDuration) { return "<=" + normalizedDuration; } else { return ">" + maxDuration; } }
TimingUtils { public static String normalizeDuration(long elapsedDuration, int sectionDurationMs, int maxSection) { long normalizedDuration; if (elapsedDuration % sectionDurationMs == 0) { normalizedDuration = elapsedDuration; } else { normalizedDuration = (elapsedDuration + sectionDurationMs) / sectionDurationMs * sectionDurationMs; } final int maxDuration = sectionDurationMs * maxSection; if (normalizedDuration <= maxDuration) { return "<=" + normalizedDuration; } else { return ">" + maxDuration; } } }
TimingUtils { public static String normalizeDuration(long elapsedDuration, int sectionDurationMs, int maxSection) { long normalizedDuration; if (elapsedDuration % sectionDurationMs == 0) { normalizedDuration = elapsedDuration; } else { normalizedDuration = (elapsedDuration + sectionDurationMs) / sectionDurationMs * sectionDurationMs; } final int maxDuration = sectionDurationMs * maxSection; if (normalizedDuration <= maxDuration) { return "<=" + normalizedDuration; } else { return ">" + maxDuration; } } private  TimingUtils(); }
TimingUtils { public static String normalizeDuration(long elapsedDuration, int sectionDurationMs, int maxSection) { long normalizedDuration; if (elapsedDuration % sectionDurationMs == 0) { normalizedDuration = elapsedDuration; } else { normalizedDuration = (elapsedDuration + sectionDurationMs) / sectionDurationMs * sectionDurationMs; } final int maxDuration = sectionDurationMs * maxSection; if (normalizedDuration <= maxDuration) { return "<=" + normalizedDuration; } else { return ">" + maxDuration; } } private  TimingUtils(); static void startTime(String tag); static long elapsedTime(String tag); static String getNormalizedDuration(String tag, int sectionDurationMs, int maxSection); static String normalizeDuration(long elapsedDuration, int sectionDurationMs, int maxSection); }
TimingUtils { public static String normalizeDuration(long elapsedDuration, int sectionDurationMs, int maxSection) { long normalizedDuration; if (elapsedDuration % sectionDurationMs == 0) { normalizedDuration = elapsedDuration; } else { normalizedDuration = (elapsedDuration + sectionDurationMs) / sectionDurationMs * sectionDurationMs; } final int maxDuration = sectionDurationMs * maxSection; if (normalizedDuration <= maxDuration) { return "<=" + normalizedDuration; } else { return ">" + maxDuration; } } private  TimingUtils(); static void startTime(String tag); static long elapsedTime(String tag); static String getNormalizedDuration(String tag, int sectionDurationMs, int maxSection); static String normalizeDuration(long elapsedDuration, int sectionDurationMs, int maxSection); static final int SECTION_DURATION_10_MS; static final int SECTION_DURATION_20_MS; static final int SECTION_DURATION_50_MS; static final int SECTION_DURATION_100_MS; static final int SECTION_DURATION_500_MS; static final int MAX_SECTION_10; static final int MAX_SECTION_20; static final int MAX_SECTION_40; static final int MAX_SECTION_50; static final int MAX_SECTION_100; }