changed: update version strings for beta4
[xbmc.git] / xbmc / utils / PerformanceSample.h
blob439394df1a413206525e6817de4be11e2e6129a1
1 #ifndef __PERFORMANCE_SAMPLE__
2 #define __PERFORMANCE_SAMPLE__
4 /*
5 * Copyright (C) 2005-2008 Team XBMC
6 * http://www.xbmc.org
8 * This Program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
13 * This Program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with XBMC; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 * http://www.gnu.org/copyleft/gpl.html
25 #ifdef _LINUX
26 #include "linux/PlatformDefs.h"
27 #include <sys/time.h>
28 #include <sys/times.h>
29 #include <sys/resource.h>
30 #endif
32 #include <string>
34 #ifndef NO_PERFORMANCE_MEASURE
35 #define MEASURE_FUNCTION CPerformanceSample aSample(__FUNCTION__,true);
36 #define BEGIN_MEASURE_BLOCK(n) { CPerformanceSample aSample(n,true);
37 #define END_MEASURE_BLOCK }
38 #else
39 #define MEASURE_FUNCTION
40 #define BEGIN_MEASURE_BLOCK(n)
41 #define END_MEASURE_BLOCK
42 #endif
44 class CPerformanceSample
46 public:
47 CPerformanceSample(const std::string &statName, bool bCheckWhenDone=true);
48 virtual ~CPerformanceSample();
50 void Reset();
51 void CheckPoint(); // will add a sample to stats and restart counting.
53 static double GetEstimatedError();
55 protected:
56 std::string m_statName;
57 bool m_bCheckWhenDone;
59 #ifdef _LINUX
60 struct rusage m_usage;
61 #endif
63 int64_t m_tmStart;
64 static int64_t m_tmFreq;
67 #endif