• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

kcachegrind

  • sources
  • kde-4.12
  • kdesdk
  • kcachegrind
  • libcore
costitem.h
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2002 - 2009 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
3 
4  KCachegrind is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation, version 2.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #ifndef COST_H
20 #define COST_H
21 
22 #include <QString>
23 
24 #include "subcost.h"
25 #include "context.h"
26 #include "utils.h"
27 
28 class EventType;
29 class EventTypeSet;
30 class EventTypeMapping;
31 class TracePart;
32 class TraceData;
33 
37 class CostItem
38 {
39 public:
40 
41  CostItem(ProfileContext*);
42  virtual ~CostItem();
43 
44  ProfileContext* context() const { return _context; }
45  ProfileContext::Type type() const { return context()->type(); }
46 
50  virtual QString name() const;
51 
55  virtual QString prettyName() const;
56 
60  virtual QString formattedName() const;
61 
65  virtual QString costString(EventTypeSet*);
66 
70  QString fullName() const;
71 
75  QString toString();
76 
80  virtual void clear();
81 
89  virtual void invalidate();
90 
95  void setDependant(CostItem* d) { _dep = d; }
96 
97  CostItem* dependant() { return _dep; }
98 
103  void setPosition(CostItem* p) { _position = p; }
104 
108  void setContext(ProfileContext* context) { _context = context; }
109 
110  // getters for specific positions, to be overwritten
111  virtual TracePart* part();
112  virtual const TracePart* part() const;
113  virtual TraceData* data();
114  virtual const TraceData* data() const;
115 
116  protected:
121  virtual void update();
122 
123  ProfileContext* _context;
124  bool _dirty;
125 
126  CostItem* _position;
127  CostItem* _dep;
128 };
129 
130 
131 // The maximal number of subcosts in a ProfileCostArray and
132 // event types in a EventSet. Does not really matter for memory
133 // consumption as cost for a ProfileCostArray is dynamically
134 // allocated depending on used number of event types, and there
135 // will be only a low number of objects for EventType{,Set,Mapping}.
136 #define MaxRealIndexValue 200
137 
144 class ProfileCostArray: public CostItem
145 {
146  friend class EventType;
147 public:
150  static const int MaxRealIndex;
151  static const int InvalidIndex;
152 
153 
154  ProfileCostArray(ProfileContext*);
155  ProfileCostArray();
156  virtual ~ProfileCostArray();
157 
158  virtual QString costString(EventTypeSet*);
159 
160  virtual void clear();
161 
162  // reserve space for cost
163  void reserve(int);
164 
165  // set costs according to the mapping order of event types
166  void set(EventTypeMapping*, const char*);
167  void set(EventTypeMapping*, FixString&);
168  // add costs according to the mapping order of event types
169  void addCost(EventTypeMapping*, const char*);
170  void addCost(EventTypeMapping*, FixString&);
171  // add the cost of another item
172  void addCost(ProfileCostArray* item);
173  void addCost(int index, SubCost value);
174 
175  // maximal cost
176  void maxCost(EventTypeMapping*, FixString&);
177  void maxCost(ProfileCostArray* item);
178  void maxCost(int index, SubCost value);
179  ProfileCostArray diff(ProfileCostArray* item);
180 
181  virtual void invalidate();
182 
186  SubCost subCost(EventType*);
187 
191  QString prettySubCost(EventType*);
192 
193  QString prettySubCostPerCall(EventType* t, int calls);
194 
195  protected:
196  virtual void update();
197 
198  private:
199  // Only used by friend class EventType: return subcost by index
200  SubCost subCost(int);
201 
202  SubCost* _cost;
203  int _count; // only _count first indexes of _cost are used
204  int _allocCount; // number of allocated subcost entries
205 
206  // cache last virtual subcost for faster access
207  SubCost _cachedCost;
208  EventType* _cachedType;
209 };
210 
211 
212 #endif // COST_H
ProfileCostArray::reserve
void reserve(int)
Definition: costitem.cpp:160
ProfileContext::type
ProfileContext::Type type()
Definition: context.h:55
CostItem::part
virtual TracePart * part()
Definition: costitem.cpp:101
ProfileCostArray::subCost
SubCost subCost(EventType *)
Returns a sub cost.
Definition: costitem.cpp:591
CostItem::_dep
CostItem * _dep
Definition: costitem.h:127
context.h
CostItem::costString
virtual QString costString(EventTypeSet *)
Returns text of all cost metrics.
Definition: costitem.cpp:48
ProfileCostArray::MaxRealIndex
static const int MaxRealIndex
Definition: costitem.h:150
CostItem::update
virtual void update()
Updates cost attributes.
Definition: costitem.cpp:96
CostItem::type
ProfileContext::Type type() const
Definition: costitem.h:45
ProfileCostArray::prettySubCost
QString prettySubCost(EventType *)
Returns a cost attribute converted to a string (with space after every 3 digits)
Definition: costitem.cpp:601
CostItem::~CostItem
virtual ~CostItem()
Definition: costitem.cpp:38
CostItem::setContext
void setContext(ProfileContext *context)
Redefine the context after construction.
Definition: costitem.h:108
ProfileCostArray::invalidate
virtual void invalidate()
Invalidate the cost attributes.
Definition: costitem.cpp:562
CostItem::CostItem
CostItem(ProfileContext *)
Definition: costitem.cpp:29
CostItem
Base class for cost items.
Definition: costitem.h:37
ProfileCostArray::InvalidIndex
static const int InvalidIndex
Definition: costitem.h:151
ProfileCostArray::set
void set(EventTypeMapping *, const char *)
Definition: costitem.cpp:175
ProfileCostArray::costString
virtual QString costString(EventTypeSet *)
Returns text of all cost metrics.
Definition: costitem.cpp:545
EventTypeMapping
A index list into a EventTypeSet.
Definition: eventtype.h:170
EventType
A cost type, e.g.
Definition: eventtype.h:43
ProfileCostArray::update
virtual void update()
Updates cost attributes.
Definition: costitem.cpp:572
CostItem::formattedName
virtual QString formattedName() const
A HTMLified version of name, can return empty string.
Definition: costitem.cpp:71
ProfileCostArray::~ProfileCostArray
virtual ~ProfileCostArray()
Definition: costitem.cpp:148
utils.h
ProfileCostArray::maxCost
void maxCost(EventTypeMapping *, FixString &)
Definition: costitem.cpp:358
ProfileCostArray
An array of basic cost metrics for a trace item.
Definition: costitem.h:144
CostItem::dependant
CostItem * dependant()
Definition: costitem.h:97
CostItem::clear
virtual void clear()
Set all cost counters to zero.
Definition: costitem.cpp:42
ProfileContext
Base class for source contexts which event costs contained in a ProfileData instance, ie.
Definition: context.h:32
subcost.h
CostItem::name
virtual QString name() const
Returns dynamic name info (without type)
Definition: costitem.cpp:53
CostItem::fullName
QString fullName() const
Returns type name + dynamic name.
Definition: costitem.cpp:76
CostItem::context
ProfileContext * context() const
Definition: costitem.h:44
CostItem::setPosition
void setPosition(CostItem *p)
If this item is from a single profile data file, position points to a TracePart, otherwise to a Trace...
Definition: costitem.h:103
CostItem::data
virtual TraceData * data()
Definition: costitem.cpp:111
FixString
A simple, constant string class.
Definition: utils.h:38
CostItem::invalidate
virtual void invalidate()
Invalidate the cost attributes.
Definition: costitem.cpp:87
ProfileCostArray::prettySubCostPerCall
QString prettySubCostPerCall(EventType *t, int calls)
Definition: costitem.cpp:606
TracePart
A Trace Part: All data read from a trace file, containing all costs that happened in a specified time...
Definition: tracedata.h:655
ProfileCostArray::clear
virtual void clear()
Set all cost counters to zero.
Definition: costitem.cpp:154
CostItem::_context
ProfileContext * _context
Definition: costitem.h:123
CostItem::_dirty
bool _dirty
Definition: costitem.h:124
CostItem::_position
CostItem * _position
Definition: costitem.h:126
ProfileContext::Type
Type
Definition: context.h:36
SubCost
Cost event counter, simple wrapper around a 64bit entity.
Definition: subcost.h:32
ProfileCostArray::addCost
void addCost(EventTypeMapping *, const char *)
Definition: costitem.cpp:252
EventTypeSet
A class for managing a set of event types.
Definition: eventtype.h:117
CostItem::toString
QString toString()
Returns full name + cost text.
Definition: costitem.cpp:82
TraceData
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
Definition: tracedata.h:1363
CostItem::prettyName
virtual QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
Definition: costitem.cpp:65
ProfileCostArray::ProfileCostArray
ProfileCostArray()
Definition: costitem.cpp:139
CostItem::setDependant
void setDependant(CostItem *d)
Sets a dependant to be invalidated when this cost is invalidated.
Definition: costitem.h:95
ProfileCostArray::diff
ProfileCostArray diff(ProfileCostArray *item)
Definition: costitem.cpp:526
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcachegrind

Skip menu "kcachegrind"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal