Coverage Report - sk.baka.webvm.analyzer.ICpuUsageMeasure
 
Classes in this File Line Coverage Branch Coverage Complexity
ICpuUsageMeasure
N/A
N/A
1
 
 1  
 /**
 2  
  * Copyright 2009 Martin Vysny.
 3  
  *
 4  
  * This file is part of WebVM.
 5  
  *
 6  
  * WebVM is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License, or
 9  
  * (at your option) any later version.
 10  
  *
 11  
  * WebVM is distributed in the hope that it will be useful,
 12  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14  
  * GNU General Public License for more details.
 15  
  *
 16  
  * You should have received a copy of the GNU General Public License
 17  
  * along with WebVM.  If not, see <http://www.gnu.org/licenses/>.
 18  
  */
 19  
 package sk.baka.webvm.analyzer;
 20  
 
 21  
 /**
 22  
  * Interface for measuring CPU usage.
 23  
  * @author mvy
 24  
  */
 25  
 public interface ICpuUsageMeasure {
 26  
 
 27  
     /**
 28  
      * Checks if this particular implementation is supported on given host OS.
 29  
      * @return true if it is supported, false otherwise.
 30  
      */
 31  
     boolean supported();
 32  
 
 33  
     /**
 34  
      * Measures an implementation-dependent CPU usage statistics. Used in {@link #getAvgCpuUsage(java.lang.Object, java.lang.Object)} to compute the real CPU usage.
 35  
      * @return the measurement object
 36  
      * @throws Exception if something happens.
 37  
      */
 38  
     Object measure() throws Exception;
 39  
 
 40  
     /**
 41  
      * Computes an average CPU usage between two measurements. The first measurement was taken before the second one was taken.<p/>
 42  
      * The method must not fail if m1 is same as m2 - in such case return 0.
 43  
      * @param m1 first measurement.
 44  
      * @param m2 second measurement
 45  
      * @return CPU usage in percent, must be a value between 0 and 100.
 46  
      */
 47  
     int getAvgCpuUsage(final Object m1, final Object m2);
 48  
 }