Code example for Stopwatch

0
    } 
 
    @Override 
    public void run() { 
        Timer.Context context = metrics.totalReadTime.time();
        Stopwatch stopwatch = new Stopwatch().start();
        try { 
            log.info("Running metrics queries");
 
            ThreadLocalRandom random = ThreadLocalRandom.current();
            int bound = startingSchedule + batchSize;
 
            findResourceDataForPast24Hours(random.nextInt(startingSchedule, bound));
            findResourceDataForPastWeek(random.nextInt(startingSchedule, bound));
            findResourceDataForPast2Weeks(random.nextInt(startingSchedule, bound));
            findResourceDataForPast31Days(random.nextInt(startingSchedule, bound));
            findResourceDataForPastYear(random.nextInt(startingSchedule, bound));
        } finally { 
            stopwatch.stop();
            log.info("Finished running metrics queries in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
Experience pair programming with AI  Get Codota for Java