Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 3487)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 3497)
@@ -90,5 +90,7 @@
 
 #include <fstream>
-#include <TBaseClass.h>
+
+#include <TBaseClass.h> // OverwritesProcess
+#include <TStopwatch.h> // TStopwatch
 
 #include "MLog.h"
@@ -103,5 +105,6 @@
 
 MTask::MTask(const char *name, const char *title)
-    : fFilter(NULL), fSerialNumber(0), fIsPreprocessed(kFALSE), fNumExecutions(0)
+    : fFilter(NULL), fSerialNumber(0), fIsPreprocessed(kFALSE),
+    fNumExecutions(0), fStopwatch(0)
 {
     fName  = name  ? name  : "MTask";
@@ -110,8 +113,11 @@
     fListOfBranches = new TList;
     fListOfBranches->SetOwner();
+
+    fStopwatch = new TStopwatch;
 }
 
 MTask::~MTask()
 {
+    delete fStopwatch;
     delete fListOfBranches;
 }
@@ -184,8 +190,10 @@
 // Mapper function for PreProcess.
 // Sets the preprocessed flag dependend on the return value of PreProcess.
+// Resets number of executions and cpu consumtion timer.
 //
 Int_t MTask::CallPreProcess(MParList *plist)
 {
     fNumExecutions = 0;
+    fStopwatch->Reset();
 
     *fLog << all << fName << "... " << flush;
@@ -218,4 +226,5 @@
 // return value.
 // If Process is executed, the execution counter is increased.
+// Count cpu consumtion time.
 //
 Int_t MTask::CallProcess()
@@ -232,5 +241,10 @@
 
     fNumExecutions++;
-    return Process();
+
+    fStopwatch->Start(kFALSE);
+    const Int_t rc = Process();
+    fStopwatch->Stop();
+
+    return rc;
 }
 
@@ -332,5 +346,24 @@
 // --------------------------------------------------------------------------
 //
-//  Prints the number of times all the tasks in the list has been.
+//  Return total CPU execution time of task
+//
+Double_t MTask::GetCpuTime() const
+{
+    return fStopwatch->CpuTime();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return total real execution time of task
+//
+Double_t MTask::GetRealTime() const
+{
+    return fStopwatch->RealTime();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints the relative time spent in Process() (relative means relative to
+//  its parent Tasklist) and the number of times Process() was executed.
 //  For convinience the lvl argument results in a number of spaces at the
 //  beginning of the line. So that the structur of a tasklist can be
@@ -338,8 +371,17 @@
 //  filter is printer in <>-brackets behind the number of executions.
 //  Use MTaskList::PrintStatistics without an argument.
-//
-void MTask::PrintStatistics(const Int_t lvl, Bool_t title) const
-{
-    *fLog << all << setfill(' ') << setw(lvl) << " " << GetDescriptor() << "\t";
+//  For tasks which don't overwrite Process() no action is perfomed.
+//
+void MTask::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
+{
+    if (!OverwritesProcess())
+        return;
+
+    *fLog << all << setfill(' ') << setw(lvl) << " ";
+    if (fStopwatch->CpuTime()>0 && time>0)
+        *fLog << setw(3) << (Int_t)(fStopwatch->CpuTime()/time*100+.5) << "% ";
+    else
+        *fLog << "     ";
+    *fLog << GetDescriptor() << "\t";
     *fLog << dec << fNumExecutions;
     if (fFilter)
Index: trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.h	(revision 3487)
+++ trunk/MagicSoft/Mars/mbase/MTask.h	(revision 3497)
@@ -15,4 +15,5 @@
 
 class TList;
+class TStopwatch;
 
 class MFilter;
@@ -29,4 +30,6 @@
     Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList)
     UInt_t fNumExecutions;  //! Number of Excutions
+
+    TStopwatch *fStopwatch; //!
 
     virtual Int_t PreProcess(MParList *pList);
@@ -66,11 +69,16 @@
     virtual ~MTask();
 
+    const TList *GetListOfBranches() const { return fListOfBranches; }
+    Bool_t OverwritesProcess(TClass *cls=NULL) const;
+
+    // Filter functions
     virtual void SetFilter(MFilter *filter) { fFilter=filter; }
     const MFilter *GetFilter() const      { return fFilter; }
     MFilter *GetFilter()  { return fFilter; } // for MContinue only
 
+    // Display functions
     void SetDisplay(MStatusDisplay *d);
-    virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
 
+    // Function for parallel executions
     static TString AddSerialNumber(const char *str, UInt_t num) { TString s(str); if (num==0) return s; s += ";"; s += num; return s; }
     static TString AddSerialNumber(const TString &str, UInt_t num) { return AddSerialNumber((const char*)str, num); }
@@ -83,6 +91,11 @@
     const char *GetDescriptor() const;
 
+    // Task execution statistics
     UInt_t GetNumExecutions() const { return fNumExecutions; }
+    Double_t GetCpuTime() const;
+    Double_t GetRealTime() const;
+    virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
 
+    // Task overwrite functions
     virtual Bool_t ReInit(MParList *pList);
 
@@ -90,8 +103,4 @@
     virtual Int_t CallProcess();
     virtual Int_t CallPostProcess();
-
-    const TList *GetListOfBranches() const { return fListOfBranches; }
-
-    Bool_t OverwritesProcess(TClass *cls=NULL) const;
 
     void SavePrimitive(ofstream &out, Option_t *o="");
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 3487)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 3497)
@@ -16,7 +16,7 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -24,42 +24,40 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MTaskList                                                               //
-//                                                                         //
-// Collection of tasks.                                                    //
-//                                                                         //
-// A tasklist is necessary to run the eventloop. It contains the scheduled //
-// tasks, which should be executed in your program.                        //
-//                                                                         //
-// To add a task use AddToList.                                            //
-//                                                                         //
-// The tasklist itself is a task, too. You can add a tasklist to another   //
-// tasklist. This makes sense, if you want to filter the execution of      //
-// more than one task of your tasklist using the same filter.              //
-//                                                                         //
-// The tasks in the list are idetified by their names. If more than one    //
-// task has the same name, the tasklist will still work correctly, but     //
-// you might run into trouble trying to get a pointer to a task by name    //
-// from the list.                                                          //
-//                                                                         //
-// Warning:                                                                //
-//  Be carefull if you are writing your tasklist                           //
-//  (eg. MWriteRootFile("file.root", "MTaskList")) to a file. You may      //
-//  not be able to initialize a new working tasklist from a file if        //
-//   a) Two Paramerer containers with the same names are existing in the   //
-//      MParList.                                                          //
-//   b) You used a container somewhere which is not part of MParList.      //
-//      (eg. You specified a pointer to a MH container in MFillH which is  //
-//      not added to the parameter list.                                   //
-//                                                                         //
+//
+// MTaskList
+//
+// Collection of tasks.
+//
+// A tasklist is necessary to run the eventloop. It contains the scheduled
+// tasks, which should be executed in your program.
+//
+// To add a task use AddToList.
+//
+// The tasklist itself is a task, too. You can add a tasklist to another
+// tasklist. This makes sense, if you want to filter the execution of
+// more than one task of your tasklist using the same filter.
+//
+// The tasks in the list are idetified by their names. If more than one
+// task has the same name, the tasklist will still work correctly, but
+// you might run into trouble trying to get a pointer to a task by name
+// from the list.
+//
+// Warning:
+//  Be carefull if you are writing your tasklist
+//  (eg. MWriteRootFile("file.root", "MTaskList")) to a file. You may
+//  not be able to initialize a new working tasklist from a file if
+//   a) Two Paramerer containers with the same names are existing in the
+//      MParList.
+//   b) You used a container somewhere which is not part of MParList.
+//      (eg. You specified a pointer to a MH container in MFillH which is
+//      not added to the parameter list.
+//
 /////////////////////////////////////////////////////////////////////////////
-
 #include "MTaskList.h"
 
-#include <fstream>        // ofstream, SavePrimitive
-
-#include <TClass.h>
-#include <TSystem.h>        // gSystem
-#include <TOrdCollection.h>
+#include <fstream>           // ofstream, SavePrimitive
+
+#include <TSystem.h>         // gSystem
+#include <TOrdCollection.h>  // TOrdCollection
 
 #include "MLog.h"
@@ -627,9 +625,9 @@
 //  Use MTaskList::PrintStatistics without an argument.
 //
-void MTaskList::PrintStatistics(const Int_t lvl, Bool_t title) const
+void MTaskList::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
 {
     if (lvl==0)
     {
-        *fLog << all << underline << "Execution Statistics:" << endl;
+        *fLog << all << underline << "Process execution Statistics:" << endl;
         *fLog << GetDescriptor();
         if (GetFilter())
@@ -640,10 +638,10 @@
     }
     else
-        MTask::PrintStatistics(lvl, title);
+        MTask::PrintStatistics(lvl, title, time);
 
     //
     //  create the Iterator for the TaskList
     //
-    fTasks->ForEach(MTask, PrintStatistics)(lvl+1, title);
+    fTasks->ForEach(MTask, PrintStatistics)(lvl+1, title, GetCpuTime());
 
     if (lvl==0)
@@ -651,6 +649,8 @@
 }
 
-
-// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+//
+// Call 'Print()' of all tasks
+//
 void MTaskList::Print(Option_t *t) const
 {
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 3487)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 3497)
@@ -70,5 +70,5 @@
 
     void Print(Option_t *opt = "") const;
-    void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
+    void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
     void SetOwner(Bool_t enable=kTRUE);
 
