org/objectweb/proactive/calcium/statistics/StatsGlobalImpl.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.calcium.statistics;
00032 
00033 import org.objectweb.proactive.calcium.Task;
00034 
00044 public class StatsGlobalImpl implements java.io.Serializable, StatsGlobal{
00045 
00046         private int processingQueueLength, waitingQueueLength, readyQueueLength, resultsQueueLength;
00047         private int solvedNumberTasks, solvedRootTasks;
00048         private long processingTime, waitingTime, readyTime, resultsTime, wallclockTime,computationTime;
00049         
00050         public StatsGlobalImpl(){
00051                 solvedNumberTasks=solvedRootTasks=readyQueueLength=0;
00052         }
00053         
00054         public void setQueueLengths(int readyQ, int processingQ, int waitingQ, int resultsQ){
00055                 this.readyQueueLength=readyQ;
00056                 this.processingQueueLength=processingQ;
00057                 this.waitingQueueLength=waitingQ;
00058                 this.resultsQueueLength=resultsQ;
00059         }
00060         
00061         public synchronized void increaseSolvedTasks(Task<?> task){
00062                 solvedNumberTasks++;
00063                 Stats taskStats=task.getStats();
00064                 computationTime+=taskStats.getComputationTime();
00065                 processingTime += taskStats.getProcessingTime();
00066                 readyTime += taskStats.getReadyTime();
00067                 resultsTime += taskStats.getResultsTime();
00068                 waitingTime += taskStats.getWaitingTime();
00069                 wallclockTime += taskStats.getProcessingTime();
00070                 
00071                 if(task.isRootTask()){
00072                         solvedRootTasks++;
00073                 }
00074         }
00075         
00076         public String toString(){
00077                 
00078                 String ls=System.getProperty("line.separator");
00079                 
00080                 return 
00081                 "Queue Lengths:  "+readyQueueLength+"R "+processingQueueLength+"P "+waitingQueueLength+"W "+resultsQueueLength+"F"+ls+
00082                 "Average Times:  "+getAverageReadyTime()+"R "+getAverageProcessingTime()+"P "+
00083                 getAverageWaitingTime()+"W "+getAverageResultsTime()+"F "+
00084                 getAverageWallClockTime()+"L "+getAverageComputationTime()+"C [ms]"+ls+
00085                 
00086                 "Computed Tasks: "+getSolvedNumberOfRootTasks() +"[Root] " + getSolvedNumberOfTasks()+"[Total]";
00087         }
00088 
00089         
00090         // ********* INTERFACE METHODS BEGIN HERE   ************
00091         
00092         public int getReadyQueueLength(){
00093                 return readyQueueLength;
00094         }
00095         
00096         public int getSolvedNumberOfTasks(){
00097                 return solvedNumberTasks;
00098         }
00099         
00100         public int getSolvedNumberOfRootTasks(){
00101                 return solvedRootTasks;
00102         }
00103         
00104         public int getProccessingQueueLength() {
00105                 return processingQueueLength;
00106         }
00107 
00108         public int getWaitingQueueLength() {
00109                 return waitingQueueLength;
00110         }
00111 
00112         public int getResultsQueueLength() {
00113                 return resultsQueueLength;
00114         }
00115 
00116         public long getAverageWallClockTime() {
00117                 if(solvedNumberTasks == 0 ) return 0;
00118                 return wallclockTime/solvedNumberTasks;
00119         }
00120 
00121         public long getAverageProcessingTime() {
00122                 if(solvedNumberTasks == 0 ) return 0;
00123                 return processingTime/solvedNumberTasks;
00124         }
00125 
00126         public long getAverageWaitingTime() {
00127                 if(solvedNumberTasks == 0 ) return 0;
00128                 return waitingTime/solvedNumberTasks;
00129         }
00130 
00131         public long getAverageResultsTime() {
00132                 if(solvedNumberTasks == 0 ) return 0;
00133                 return resultsTime/solvedNumberTasks;
00134         }
00135         
00136         public long getAverageReadyTime() {
00137                 if(solvedNumberTasks == 0 ) return 0;
00138                 return readyTime/solvedNumberTasks;
00139         }
00140         
00141         public long getAverageComputationTime(){
00142                 if(solvedNumberTasks == 0 ) return 0;
00143                 return computationTime/solvedNumberTasks;
00144         }
00145 }

Generated on Mon Jan 22 15:16:05 2007 for ProActive by  doxygen 1.5.1