Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsperf.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #ifndef MMSPERF_H_
00034 #define MMSPERF_H_
00035 
00036 #include "mmstools/mmsthread.h"
00037 #include "mmsgui/fb/mmsfbsurface.h"
00038 
00039 #if MMSFB_BLIT_CNT > MMSFB_DRAW_CNT
00040     #define MMSFBPERF_MAXFLAGS  MMSFB_BLIT_CNT
00041 #else
00042     #define MMSFBPERF_MAXFLAGS  MMSFB_DRAW_CNT
00043 #endif
00044 
00045 typedef struct {
00046     unsigned int calls;
00047     unsigned int mpixels;
00048     unsigned int rpixels;
00049     unsigned int usecs;
00050     unsigned int mpps;
00051 } MMSFBPERF_MEASURING_VALS;
00052 
00053 typedef MMSFBPERF_MEASURING_VALS MMSFBPERF_MEASURING_LIST[2][MMSFB_PF_CNT][MMSFB_PF_CNT][MMSFBPERF_MAXFLAGS];
00054 
00055 
00056 #define MMSFBPERF_MAXVKEYS  1024
00057 
00058 typedef struct {
00059     unsigned int calls;
00060     unsigned int usecs;
00061 } MMSFBPERF_MEASURING_VALS_VKEY;
00062 
00063 typedef MMSFBPERF_MEASURING_VALS_VKEY MMSFBPERF_MEASURING_LIST_VKEY[MMSFBPERF_MAXVKEYS];
00064 
00065 
00066 class MMSPerf {
00067 private:
00068 
00069     //! already initialized?
00070     static bool initialized;
00071 
00072     //! make it thread-safe
00073     static MMSMutex lockme;
00074 
00075     //! start of measuring
00076     static struct timeval start_time;
00077 
00078     //! statistic for fill rectangle routines
00079     static MMSFBPERF_MEASURING_LIST fillrect;
00080 
00081     //! statistic for draw line routines
00082     static MMSFBPERF_MEASURING_LIST drawline;
00083 
00084     //! statistic for draw string routines
00085     static MMSFBPERF_MEASURING_LIST drawstring;
00086 
00087     //! statistic for blitting routines
00088     static MMSFBPERF_MEASURING_LIST blit;
00089 
00090     //! statistic for stretchblit routines
00091     static MMSFBPERF_MEASURING_LIST stretchblit;
00092 
00093     //! statistic for xshmputimage routines
00094     static MMSFBPERF_MEASURING_LIST xshmputimage;
00095 
00096     //! statistic for xvshmputimage routines
00097     static MMSFBPERF_MEASURING_LIST xvshmputimage;
00098 
00099     //! statistic for vsync routines
00100     static MMSFBPERF_MEASURING_LIST vsync;
00101 
00102     //! statistic for swapdisplay routines
00103     static MMSFBPERF_MEASURING_LIST swapdisplay;
00104 
00105 
00106     //! statistic for vkey routines
00107     static MMSFBPERF_MEASURING_LIST_VKEY vkey;
00108 
00109 
00110     void lock();
00111     void unlock();
00112 
00113     //! reset statistic infos
00114     void reset();
00115 
00116     unsigned int getDuration();
00117 
00118     void addMeasuringVals(MMSFBPERF_MEASURING_VALS *summary, MMSFBPERF_MEASURING_VALS *add_sum);
00119 
00120     void addMeasuringVals(MMSFBPERF_MEASURING_VALS_VKEY *summary, MMSFBPERF_MEASURING_VALS_VKEY *add_sum);
00121 
00122     int getPerfVals(MMSFBPERF_MEASURING_LIST *mlist, const char *prefix, char *retbuf, int retbuf_size,
00123                     MMSFBPERF_MEASURING_VALS *summary);
00124 
00125     int getPerfVals(MMSFBPERF_MEASURING_LIST_VKEY *mlist, char *retbuf, int retbuf_size,
00126                     MMSFBPERF_MEASURING_VALS_VKEY *summary);
00127 
00128     void stopMeasuring(struct timeval *perf_stime, MMSFBPERF_MEASURING_VALS *mvals,
00129                        int sw = 0, int sh = 0, int dw = 0, int dh = 0);
00130 
00131     void stopMeasuring(struct timeval *perf_stime, MMSFBPERF_MEASURING_VALS_VKEY *mvals);
00132 
00133 public:
00134     MMSPerf();
00135     ~MMSPerf();
00136 
00137     void startMeasuring(struct timeval *perf_stime);
00138 
00139     void stopMeasuringFillRectangle(struct timeval *perf_stime,
00140                                     MMSFBSurface *surface, int w, int h);
00141 
00142     void stopMeasuringDrawLine(struct timeval *perf_stime,
00143                                MMSFBSurface *surface, int pixels);
00144 
00145     void stopMeasuringDrawString(struct timeval *perf_stime,
00146                                  MMSFBSurface *surface, int w, int h);
00147 
00148     void stopMeasuringBlit(struct timeval *perf_stime,
00149                            MMSFBSurface *surface,
00150                            MMSFBSurfacePixelFormat src_pixelformat,
00151                            int sw, int sh);
00152 
00153     void stopMeasuringStretchBlit(struct timeval *perf_stime,
00154                                   MMSFBSurface *surface,
00155                                   MMSFBSurfacePixelFormat src_pixelformat,
00156                                   int sw, int sh, int dw, int dh);
00157 
00158     void stopMeasuringXShmPutImage(struct timeval *perf_stime,
00159                                     MMSFBSurface *surface,
00160                                     int sw, int sh);
00161 
00162     void stopMeasuringXvShmPutImage(struct timeval *perf_stime,
00163                                     MMSFBSurface *surface,
00164                                     int sw, int sh, int dw, int dh);
00165 
00166     void stopMeasuringVSync(struct timeval *perf_stime,
00167                             MMSFBSurface *surface);
00168 
00169     void stopMeasuringSwapDisplay(struct timeval *perf_stime,
00170                                     MMSFBSurface *surface);
00171 
00172     friend class MMSPerfInterface;
00173 };
00174 
00175 #endif /* MMSPERF_H_ */

Generated by doxygen