annotate base/Profiler.h @ 142:0ba66b160a02

* Add frequency plot to window shape preference -- just because... * Fix some window shapes
author Chris Cannam
date Mon, 24 Jul 2006 14:36:35 +0000
parents d397ea0a79f5
children 4b2ea82fd0ed
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@0 7
Chris@52 8 This program is free software; you can redistribute it and/or
Chris@52 9 modify it under the terms of the GNU General Public License as
Chris@52 10 published by the Free Software Foundation; either version 2 of the
Chris@52 11 License, or (at your option) any later version. See the file
Chris@52 12 COPYING included with this distribution for more information.
Chris@0 13 */
Chris@0 14
Chris@0 15 /*
Chris@0 16 This is a modified version of a source file from the
Chris@0 17 Rosegarden MIDI and audio sequencer and notation editor.
Chris@17 18 This file copyright 2000-2006 Chris Cannam and Guillaume Laurent.
Chris@0 19 */
Chris@0 20
Chris@0 21
Chris@0 22 #ifndef _PROFILER_H_
Chris@0 23 #define _PROFILER_H_
Chris@0 24
Chris@0 25 #include "System.h"
Chris@0 26
Chris@0 27 #include <ctime>
Chris@0 28 #include <sys/time.h>
Chris@0 29 #include <map>
Chris@0 30
Chris@0 31 #include "RealTime.h"
Chris@0 32
Chris@0 33
Chris@0 34 /**
Chris@0 35 * Profiling classes
Chris@0 36 */
Chris@0 37
Chris@0 38 /**
Chris@0 39 * The class holding all profiling data
Chris@0 40 *
Chris@0 41 * This class is a singleton
Chris@0 42 */
Chris@0 43 class Profiles
Chris@0 44 {
Chris@0 45 public:
Chris@0 46 static Profiles* getInstance();
Chris@0 47 ~Profiles();
Chris@0 48
Chris@0 49 void accumulate(const char* id, clock_t time, RealTime rt);
Chris@0 50 void dump();
Chris@0 51
Chris@0 52 protected:
Chris@0 53 Profiles();
Chris@0 54
Chris@0 55 typedef std::pair<clock_t, RealTime> TimePair;
Chris@0 56 typedef std::pair<int, TimePair> ProfilePair;
Chris@0 57 typedef std::map<const char *, ProfilePair> ProfileMap;
Chris@0 58 typedef std::map<const char *, TimePair> LastCallMap;
Chris@0 59 ProfileMap m_profiles;
Chris@0 60 LastCallMap m_lastCalls;
Chris@0 61
Chris@0 62 static Profiles* m_instance;
Chris@0 63 };
Chris@0 64
Chris@0 65 class Profiler
Chris@0 66 {
Chris@0 67 public:
Chris@0 68 Profiler(const char*, bool showOnDestruct = false);
Chris@0 69 ~Profiler();
Chris@0 70
Chris@0 71 void update();
Chris@0 72
Chris@0 73 protected:
Chris@0 74 const char* m_c;
Chris@0 75 clock_t m_startCPU;
Chris@0 76 RealTime m_startTime;
Chris@0 77 bool m_showOnDestruct;
Chris@0 78 };
Chris@0 79
Chris@0 80
Chris@0 81 #endif