24 #define TRACE_ASSERTIONS 0
150 if (_cost)
delete[] _cost;
162 if (count <= _allocCount)
return;
167 for(
int i=0; i<_count; i++)
168 newcost[i] = _cost[i];
177 if (!mapping)
return;
185 while(*s ==
' ') s++;
189 while(i<mapping->count()) {
190 if (!_cost[i].
set(&s))
break;
196 int i = 0, maxIndex = 0, index;
199 if (maxIndex<index) maxIndex=index;
201 if (!_cost[index].
set(&s))
break;
209 Q_ASSERT(_count <= _allocCount);
216 if (!mapping)
return;
227 while(i<mapping->count()) {
234 int i = 0, maxIndex = 0, index;
237 if (maxIndex<index) maxIndex=index;
247 Q_ASSERT(_count <= _allocCount);
254 if (!mapping || !s)
return;
260 while(i<mapping->count()) {
261 if (!v.set(&s))
break;
268 if (i > _count) _count = i;
271 int i = 0, maxIndex = 0, index;
273 if (!v.set(&s))
break;
275 if (maxIndex<index) maxIndex=index;
283 if (maxIndex >= _count) {
292 Q_ASSERT(_count <= _allocCount);
297 qDebug(
"%s\n now %s", qPrintable(
fullName() ),
305 if (!mapping)
return;
313 while(i<mapping->count()) {
321 if (i > _count) _count = i;
324 int i = 0, maxIndex = 0, index;
328 if (maxIndex<index) maxIndex=index;
336 if (maxIndex >= _count) {
345 Q_ASSERT(_count <= _allocCount);
350 qDebug(
"%s\n now %s", qPrintable(
fullName() ),
360 if (!mapping)
return;
368 while(i<mapping->count()) {
371 if (v>_cost[i]) _cost[i] = v;
377 if (i > _count) _count = i;
380 int i = 0, maxIndex = 0, index;
384 if (maxIndex<index) maxIndex=index;
387 if (v>_cost[index]) _cost[index] = v;
393 if (maxIndex >= _count) {
402 Q_ASSERT(_count <= _allocCount);
407 qDebug(
"%s\n now %s", qPrintable(
fullName() ),
426 if (item->_count < _count) {
427 for (i = 0; i<item->_count; i++)
428 _cost[i] += item->_cost[i];
431 for (i = 0; i<_count; i++)
432 _cost[i] += item->_cost[i];
433 for (; i<item->_count; i++)
434 _cost[i] = item->_cost[i];
435 _count = item->_count;
438 Q_ASSERT(_count <= _allocCount);
443 qDebug(
"%s added cost item\n %s\n now %s",
463 if (item->_count < _count) {
464 for (i = 0; i<item->_count; i++)
465 if (_cost[i] < item->_cost[i]) _cost[i] = item->_cost[i];
468 for (i = 0; i<_count; i++)
469 if (_cost[i] < item->_cost[i]) _cost[i] = item->_cost[i];
470 for (; i<item->_count; i++)
471 _cost[i] = item->_cost[i];
472 _count = item->_count;
475 Q_ASSERT(_count <= _allocCount);
480 qDebug(
"%s added cost item\n %s\n now %s",
490 if (value == 0)
return;
493 if (realIndex < _count)
494 _cost[realIndex] += value;
496 for(
int i=_count;i<realIndex;i++)
498 _cost[realIndex] = value;
499 _count = realIndex+1;
502 Q_ASSERT(_count <= _allocCount);
511 if (realIndex<_count) {
512 if (value>_cost[realIndex]) _cost[realIndex] = value;
515 for(
int i=_count;i<realIndex;i++)
517 _cost[realIndex] = value;
518 _count = realIndex+1;
521 Q_ASSERT(_count <= _allocCount);
534 int maxCount = (item->_count > _count) ? item->_count : _count;
537 for (
int i=0; i<maxCount;i++)
539 res._count = maxCount;
541 Q_ASSERT(res._count <= res._allocCount);
552 for (
int i = 0; i<maxIndex; i++) {
553 if (!res.
isEmpty()) res +=
", ";
554 if (set) res += set->
type(i)->
name() +
' ';
585 if (idx>=_count)
return 0;
594 if (_cachedType != t) {
596 _cachedCost = t->
subCost(
this);
int firstUnused()
Allows an iteration over the sorted list of all real indexes not used in this mapping, up to topIndex (use ProfileCostArray::MaxRealIndex for all).
virtual TracePart * part()
SubCost subCost(EventType *)
Returns a sub cost.
void stripSpaces()
Strip leading spaces.
virtual QString costString(EventTypeSet *)
Returns text of all cost metrics.
static const int MaxRealIndex
static QString typeName(Type)
virtual void update()
Updates cost attributes.
ProfileContext::Type type() const
#define MaxRealIndexValue
QString prettySubCost(EventType *)
Returns a cost attribute converted to a string (with space after every 3 digits)
virtual void invalidate()
Invalidate the cost attributes.
unsigned long long uint64
CostItem(ProfileContext *)
Base class for cost items.
static const int InvalidIndex
void set(EventTypeMapping *, const char *)
virtual QString costString(EventTypeSet *)
Returns text of all cost metrics.
A index list into a EventTypeSet.
QString tr(const char *sourceText, const char *disambiguation, int n)
virtual void update()
Updates cost attributes.
virtual QString formattedName() const
A HTMLified version of name, can return empty string.
virtual ~ProfileCostArray()
void maxCost(EventTypeMapping *, FixString &)
An array of basic cost metrics for a trace item.
virtual void clear()
Set all cost counters to zero.
Base class for source contexts which event costs contained in a ProfileData instance, ie.
virtual QString name() const
Returns dynamic name info (without type)
QString fullName() const
Returns type name + dynamic name.
ProfileContext * context() const
virtual TraceData * data()
A simple, constant string class.
virtual void invalidate()
Invalidate the cost attributes.
QString prettySubCostPerCall(EventType *t, uint64 calls)
SubCost subCost(ProfileCostArray *)
A Trace Part: All data read from a trace file, containing all costs that happened in a specified time...
virtual void clear()
Set all cost counters to zero.
ProfileContext * _context
Cost event counter, simple wrapper around a 64bit entity.
void addCost(EventTypeMapping *, const char *)
bool stripUInt64(uint64 &, bool stripSpaces=true)
QString pretty(char sep= ' ') const
Convert SubCost value into a QString, spaced every 3 digits.
A class for managing a set of event types.
bool isIdentity()
Is this mapping the identity( i.e.
QString toString()
Returns full name + cost text.
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
virtual QString prettyName() const
Similar to name, but prettyfied = more descriptive to humans.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
ProfileCostArray diff(ProfileCostArray *item)