1 #ifndef __PERFORMANCE_SAMPLE__
2 #define __PERFORMANCE_SAMPLE__
5 * Copyright (C) 2005-2008 Team XBMC
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)
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
26 #include "linux/PlatformDefs.h"
28 #include <sys/times.h>
29 #include <sys/resource.h>
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 }
39 #define MEASURE_FUNCTION
40 #define BEGIN_MEASURE_BLOCK(n)
41 #define END_MEASURE_BLOCK
44 class CPerformanceSample
47 CPerformanceSample(const std::string
&statName
, bool bCheckWhenDone
=true);
48 virtual ~CPerformanceSample();
51 void CheckPoint(); // will add a sample to stats and restart counting.
53 static double GetEstimatedError();
56 std::string m_statName
;
57 bool m_bCheckWhenDone
;
60 struct rusage m_usage
;
64 static int64_t m_tmFreq
;