Here you can find the source of convertReportingPeriod(long profilePeriod, TimeUnit profileTimeUnit, long reportingPeriod, TimeUnit reportingTimeUnit)
Parameter | Description |
---|---|
profilePeriod | The profiling period |
profileTimeUnit | The TimeUnit for the profiling period |
reportingPeriod | The reporting period |
reportingTimeUnit | The TimeUnit for the reporting period |
public static long convertReportingPeriod(long profilePeriod, TimeUnit profileTimeUnit, long reportingPeriod, TimeUnit reportingTimeUnit)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; public class Main { /**//from w w w.j av a 2 s . c om * Convert a reporting period into the time scale of a profiling period * * @param profilePeriod The profiling period * @param profileTimeUnit The TimeUnit for the profiling period * @param reportingPeriod The reporting period * @param reportingTimeUnit The TimeUnit for the reporting period * @return The reporting period scaled to the profiling period (i.e. suitable for use like x % convertReportingPeriod(...) == 0) */ public static long convertReportingPeriod(long profilePeriod, TimeUnit profileTimeUnit, long reportingPeriod, TimeUnit reportingTimeUnit) { long convertedReportingPeriod = profileTimeUnit.convert(reportingPeriod, reportingTimeUnit); // If we profile less frequently than we want report, returning 1 would indicate we should always report if (convertedReportingPeriod <= profilePeriod) { return 1; } return convertedReportingPeriod / profilePeriod; } }