• 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
subcost.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2004 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 
20 #include "subcost.h"
21 #include "tracedata.h"
22 
23 #include <QString>
24 
25 
26 //---------------------------------------------------
27 // SubCost
28 
29 bool SubCost::set(const char** ps)
30 {
31  const char* s = *ps;
32  if (!s || (*s < '0') || (*s > '9')) return false;
33 
34  v = *s - '0';
35  s++;
36  while(*s >= '0' && *s <= '9') {
37  v = 10* v + (*s-'0');
38  s++;
39  }
40  while(*s == ' ') s++;
41  *ps = s;
42 
43  return true;
44 }
45 
46 QString SubCost::pretty(char sep) const
47 {
48  unsigned long long n = v;
49 
50  if (n==0) return QString("0");
51 
52  int i = 0;
53  QString res = "";
54 
55  while (n) {
56  if ((i>0) && !(i%3)) res = sep + res;
57  i++;
58  res = QChar('0'+int(n%10)) + res;
59  n /= 10;
60  }
61  return res;
62 }
63 
64 
65 
66 
67 // HighestCostList
68 
69 HighestCostList::HighestCostList()
70 {
71  _costType = 0;
72  clear(1);
73 }
74 
75 void HighestCostList::clear(int maxSize)
76 {
77  _maxSize = maxSize;
78  _count = 0;
79  _item.resize(maxSize);
80  _cost.resize(maxSize);
81 }
82 
83 void HighestCostList::addCost(ProfileCostArray* c, SubCost cost)
84 {
85  int i;
86 
87  if (_maxSize == 0) return;
88 
89  _count++;
90  if (_count > _maxSize) {
91  if (_cost[_maxSize-1] >= cost) return;
92  i = _maxSize-1;
93  }
94  else i = _count-1;
95 
96  for(; i>0; i--) {
97  if (_cost[i-1] >= cost) break;
98  else {
99  _cost[i] = _cost[i-1];
100  _item[i] = _item[i-1];
101  }
102  }
103  _cost[i] = cost;
104  _item[i] = c;
105 }
106 
107 
HighestCostList::maxSize
int maxSize()
Definition: subcost.h:87
HighestCostList::HighestCostList
HighestCostList()
Definition: subcost.cpp:69
HighestCostList::clear
void clear(int maxSize)
Definition: subcost.cpp:75
SubCost::v
uint64 v
Definition: subcost.h:66
tracedata.h
ProfileCostArray
An array of basic cost metrics for a trace item.
Definition: costitem.h:144
subcost.h
HighestCostList::addCost
void addCost(ProfileCostArray *, SubCost)
Definition: subcost.cpp:83
SubCost
Cost event counter, simple wrapper around a 64bit entity.
Definition: subcost.h:32
SubCost::pretty
QString pretty(char sep= ' ') const
Convert SubCost value into a QString, spaced every 3 digits.
Definition: subcost.cpp:46
SubCost::set
bool set(const char **s)
Definition: subcost.cpp:29
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