Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.clustermate.service.util;

Simple helper class for tallying time spent on number of events (calls, reads/writes).

Instances are not thread-safe and are to be used from a single executing request thread; or, if passed along (for async processing), need to be passed in synchronizing manner.

public class TotalTime
    protected int _count;
    
    protected long _timeNanoSecs;
    
    public TotalTime(long nanoSecs) {
         = 1;
         = nanoSecs;
    }
    public static TotalTime createOrAdd(TotalTime oldlong nanoSecs)
    {
        if (old == null) {
            return new TotalTime(nanoSecs);
        }
        return old.add(nanoSecs);
    }
    
    public TotalTime add(long nanoSecs) {
        ++;
         += nanoSecs;
        return this;
    }
    
    public int getCount() { return ; }
    public long getTotalTime() { return ; }
New to GrepCode? Check out our FAQ X