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

mmsperfinterface.cpp

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 #include "mmscore/mmsperf.h"
00034 #include "mmscore/mmsperfinterface.h"
00035 
00036 #include <stdio.h>
00037 
00038 MMSPerfInterface::MMSPerfInterface(class MMSPerf *mmsfbperf) : MMSServerInterface("MMSPerfInterface") {
00039     this->mmsfbperf = mmsfbperf;
00040 }
00041 
00042 MMSPerfInterface::~MMSPerfInterface() {
00043 }
00044 
00045 void MMSPerfInterface::printHeader(char **rb, const char *title) {
00046     (*rb)+= sprintf(*rb, "\n");
00047     if (title) (*rb)+= sprintf(*rb, "%s\n\n", title);
00048     (*rb)+= sprintf(*rb, "Function      T Dest PF  Src PF   Flags Calls  MegaPix   MicroSecs   MP Per Sec\n");
00049     (*rb)+= sprintf(*rb, "-------------------------------------------------------------------------------\n");
00050 }
00051 
00052 void MMSPerfInterface::printSummary(char **rb, MMSFBPERF_MEASURING_VALS &summary) {
00053 
00054     if (summary.usecs) {
00055         // list above is not empty
00056         (*rb)+= sprintf(*rb, "-------------------------------------------------------------------------------\n");
00057     }
00058 
00059     // build summary
00060     int cnt;
00061     memset(*rb, ' ', 256);
00062 
00063     cnt = sprintf(&(*rb)[0],  "Summary");
00064     (*rb)[0 + cnt]   = ' ';
00065 
00066     cnt = sprintf(&(*rb)[40],  "%d", summary.calls);
00067     (*rb)[40 + cnt]   = ' ';
00068 
00069     cnt = sprintf(&(*rb)[47],  "%d.%03d", summary.mpixels, summary.rpixels / 1000);
00070     (*rb)[47 + cnt]  = ' ';
00071 
00072     cnt = sprintf(&(*rb)[57],  "%d", summary.usecs);
00073     (*rb)[57 + cnt]  = ' ';
00074 
00075     cnt = sprintf(&(*rb)[69],  "%d", summary.mpps);
00076     (*rb)+= 69 + cnt;
00077 
00078     (*rb)+= sprintf((*rb), "\n");
00079 }
00080 
00081 bool MMSPerfInterface::processRequest(string *request, string *answer) {
00082 
00083     if (!this->mmsfbperf) {
00084         printf("DISKO: MMSPerf not initialized, disko compiled with enable_actmon=yes?\n");
00085         return false;
00086     }
00087 
00088     if (request->substr(0, 12) == "GET_STATINFO") {
00089         // command: GET_STATINFO
00090         bool reset = false;
00091         if (request->find("RESET(TRUE)") != string::npos) {
00092             // reset perf values?
00093             reset = true;
00094         }
00095 
00096         this->mmsfbperf->lock();
00097 
00098         // char buffer to return
00099         char retbuf[65536];
00100         char *rb = retbuf;
00101 
00102         printHeader(&rb, "REPORT: DRAWING ROUTINES");
00103         MMSFBPERF_MEASURING_VALS sum_drawing;
00104         sum_drawing.calls = sum_drawing.mpixels = sum_drawing.rpixels = sum_drawing.usecs = sum_drawing.mpps = 0;
00105         rb+= this->mmsfbperf->getPerfVals(&this->mmsfbperf->fillrect,   "FILLRECT", rb, sizeof(retbuf) - (unsigned int)(rb - retbuf), &sum_drawing);
00106         rb+= this->mmsfbperf->getPerfVals(&this->mmsfbperf->drawline,   "DRAWLINE", rb, sizeof(retbuf) - (unsigned int)(rb - retbuf), &sum_drawing);
00107         rb+= this->mmsfbperf->getPerfVals(&this->mmsfbperf->drawstring, "DRAWSTRING", rb, sizeof(retbuf) - (unsigned int)(rb - retbuf), &sum_drawing);
00108         printSummary(&rb, sum_drawing);
00109 
00110         printHeader(&rb, "REPORT: BLITTING ROUTINES");
00111         MMSFBPERF_MEASURING_VALS sum_blitting;
00112         sum_blitting.calls = sum_blitting.mpixels = sum_blitting.rpixels = sum_blitting.usecs = sum_blitting.mpps = 0;
00113         rb+= this->mmsfbperf->getPerfVals(&this->mmsfbperf->blit,        "BLIT", rb, sizeof(retbuf) - (unsigned int)(rb - retbuf), &sum_blitting);
00114         rb+= this->mmsfbperf->getPerfVals(&this->mmsfbperf->stretchblit, "STRETCHBLIT", rb, sizeof(retbuf) - (unsigned int)(rb - retbuf), &sum_blitting);
00115         printSummary(&rb, sum_blitting);
00116 
00117         printHeader(&rb, "REPORT: BACKEND ROUTINES");
00118         MMSFBPERF_MEASURING_VALS sum_backend;
00119         sum_backend.calls = sum_backend.mpixels = sum_backend.rpixels = sum_backend.usecs = sum_backend.mpps = 0;
00120         rb+= this->mmsfbperf->getPerfVals(&this->mmsfbperf->xshmputimage,  "XSHMPUTIMAGE", rb, sizeof(retbuf) - (unsigned int)(rb - retbuf), &sum_backend);
00121         rb+= this->mmsfbperf->getPerfVals(&this->mmsfbperf->xvshmputimage, "XVSHMPUTIMAGE", rb, sizeof(retbuf) - (unsigned int)(rb - retbuf), &sum_backend);
00122         rb+= this->mmsfbperf->getPerfVals(&this->mmsfbperf->vsync,         "VSYNC", rb, sizeof(retbuf) - (unsigned int)(rb - retbuf), &sum_backend);
00123         rb+= this->mmsfbperf->getPerfVals(&this->mmsfbperf->swapdisplay,   "SWAPDISPLAY", rb, sizeof(retbuf) - (unsigned int)(rb - retbuf), &sum_backend);
00124         printSummary(&rb, sum_backend);
00125 
00126         rb+= sprintf(rb, "\n\nREPORT: OVER ALL SUMMARY\n\n");
00127         MMSFBPERF_MEASURING_VALS sum;
00128         sum.calls = sum.mpixels = sum.rpixels = sum.usecs = sum.mpps = 0;
00129         this->mmsfbperf->addMeasuringVals(&sum, &sum_drawing);
00130         this->mmsfbperf->addMeasuringVals(&sum, &sum_blitting);
00131         this->mmsfbperf->addMeasuringVals(&sum, &sum_backend);
00132         rb+= sprintf(rb, "        MegaPix       = %u.%u\n", sum.mpixels, sum.rpixels / 1000);
00133         rb+= sprintf(rb, "        MP Per Sec    = %u\n", sum.mpps);
00134         rb+= sprintf(rb, "        Consumed time = %d.%03ds\n", sum.usecs / 1000000, (sum.usecs % 1000000) / 1000);
00135         unsigned int dur = this->mmsfbperf->getDuration();
00136         rb+= sprintf(rb, "        Duration      = %d.%ds\n", dur / 1000, dur % 1000);
00137 
00138         // finalize
00139         rb+= sprintf(rb, "\n");
00140 
00141         *answer = retbuf;
00142 
00143         this->mmsfbperf->unlock();
00144 
00145         // reset statistic values?
00146         if (reset) {
00147             this->mmsfbperf->reset();
00148         }
00149 
00150         return true;
00151     }
00152 
00153     // unknown command
00154     return false;
00155 }

Generated by doxygen