00001 // Statistic type -*- C++ -*- 00002 /* 00003 Galois, a framework to exploit amorphous data-parallelism in irregular 00004 programs. 00005 00006 Copyright (C) 2011, The University of Texas at Austin. All rights reserved. 00007 UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS SOFTWARE 00008 AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR ANY 00009 PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF PERFORMANCE, AND ANY 00010 WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF DEALING OR USAGE OF TRADE. 00011 NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH RESPECT TO THE USE OF THE 00012 SOFTWARE OR DOCUMENTATION. Under no circumstances shall University be liable 00013 for incidental, special, indirect, direct or consequential damages or loss of 00014 profits, interruption of business, or related expenses which may arise from use 00015 of Software or Documentation, including but not limited to those resulting from 00016 defects in Software and/or Documentation, or loss or inaccuracy of data of any 00017 kind. 00018 */ 00019 00020 #ifndef __GALOIS_STATISTIC_H 00021 #define __GALOIS_STATISTIC_H 00022 00023 #include "util/Accumulator.h" 00024 #include "Runtime/Support.h" 00025 #include "Timer.h" 00026 00027 namespace Galois { 00028 00029 template<typename T> 00030 class statistic : public GAccumulator<T> { 00031 const char* name; 00032 public: 00033 statistic(const char* _name) :name(_name) {} 00034 ~statistic() { 00035 GaloisRuntime::reportStatSum(name, GAccumulator<T>::get()); 00036 } 00037 }; 00038 00039 class StatTimer : public Timer { 00040 const char* name; 00041 const char* loopname; 00042 public: 00043 StatTimer(const char* n = "Time", const char* l = 0) :name(n), loopname(l) {} 00044 ~StatTimer() { 00045 GaloisRuntime::reportStatSum(name, get(), loopname); 00046 } 00047 }; 00048 00049 } 00050 00051 #endif