Beispiel #1
0
void CoverageView::refresh()
{
    clear();

    if (!_data || !_activeItem) return;

    ProfileContext::Type t = _activeItem->type();
    TraceFunction* f = 0;
    if (t == ProfileContext::Function) f = (TraceFunction*) _activeItem;
    if (t == ProfileContext::FunctionCycle) f = (TraceFunction*) _activeItem;
    if (!f) return;



    _hc.clear(GlobalConfig::maxListCount());
    SubCost realSum = f->inclusive()->subCost(_eventType);

    TraceFunctionList l;
    if (_showCallers)
      l = Coverage::coverage(f, Coverage::Caller, _eventType);
    else
      l = Coverage::coverage(f, Coverage::Called, _eventType);

    foreach(TraceFunction* f2, l) {
      Coverage* c = (Coverage*) f2->association(Coverage::Rtti);
      if (c && (c->inclusive()>0.0))
        _hc.addCost(f2, SubCost(realSum * c->inclusive()));
    }
Beispiel #2
0
void CallerCoverageItem::update()
{
  if (!_coverage) {
    setText(0, QString::null);
    setText(1, QString::null);
    return;
  }

  _pSum = 100.0 * _coverage->inclusive();
  SubCost realSum = _base->inclusive()->subCost(_costType);
  _sum = SubCost(realSum * _coverage->inclusive());
  QString str;
  if (Configuration::showPercentage())
    str = QString("%1").arg(_pSum, 0, 'f', Configuration::percentPrecision());
  else
    str = _sum.pretty();

  if (_skipped) {
    setText(0, QString("< %1").arg(str));
    return;
  }

  setText(0, str);
  setPixmap(0, partitionPixmap(25, 10, _coverage->inclusiveHistogram(), 0,
                               Coverage::maxHistogramDepth, false));

  // call count
  _cc  = SubCost(_coverage->callCount());
  setText(2, _cc ? _cc.pretty() : QString("(0)"));

  // distance (min/max/median)
  _distance = _coverage->inclusiveMedian();
  QString distString;
  if (_coverage->minDistance() == _coverage->maxDistance())
    distString = QString::number(_distance);
  else
    distString = QString("%1-%2 (%3)")
                 .arg(_coverage->minDistance())
                 .arg(_coverage->maxDistance())
                 .arg(_distance);
  setText(1, distString);
}
Beispiel #3
0
QString ProfileCostArray::prettySubCostPerCall(EventType* t, uint64 calls)
{
    if (calls == 0) {
        /* For callgrind, a call count of zero means that
         * a function was already active when measuring started
         * (even without that possibility, we never should crash).
         * To show full cost, set <calls> to 1.
         */
        calls = 1;
    }
    return SubCost(subCost(t) / calls).pretty();
}
Beispiel #4
0
void CoverageView::refresh()
{
    clear();
    setColumnWidth(0, 50);
    if (!_showCallers)
	setColumnWidth(1, 50);

    if (!_data || !_activeItem) return;

    TraceItem::CostType t = _activeItem->type();
    TraceFunction* f = 0;
    if (t == TraceItem::Function) f = (TraceFunction*) _activeItem;
    if (t == TraceItem::FunctionCycle) f = (TraceFunction*) _activeItem;
    if (!f) return;

    TraceFunction* ff;
    TraceFunctionList l;

    _hc.clear(Configuration::maxListCount());
    SubCost realSum = f->inclusive()->subCost(_costType);

    if (_showCallers)
      l = Coverage::coverage(f, Coverage::Caller, _costType);
    else
      l = Coverage::coverage(f, Coverage::Called, _costType);

    for (ff=l.first();ff;ff=l.next()) {
      Coverage* c = (Coverage*) ff->assoziation(Coverage::Rtti);
      if (c && (c->inclusive()>0.0))
	_hc.addCost(ff, SubCost(realSum * c->inclusive()));
    }

    for(int i=0;i<_hc.realCount();i++) {
      ff = (TraceFunction*) _hc[i];
      Coverage* c = (Coverage*) ff->assoziation(Coverage::Rtti);
      if (_showCallers)
	new CallerCoverageItem(this, c, f, _costType, _groupType);
      else
	new CalleeCoverageItem(this, c, f, _costType, _groupType);
    }
    if (_hc.hasMore()) {
      // a placeholder for all the functions skipped ...
      ff = (TraceFunction*) _hc[_hc.maxSize()-1];
      Coverage* c = (Coverage*) ff->assoziation(Coverage::Rtti);
      if (_showCallers)
	new CallerCoverageItem(this, _hc.count() - _hc.maxSize(),
			       c, f, _costType, _groupType);
      else
	new CalleeCoverageItem(this, _hc.count() - _hc.maxSize(),
			       c, f, _costType, _groupType);
    }
}
Beispiel #5
0
void SourceItem::updateCost()
{
  _pure = SubCost(0);
  _pure2 = SubCost(0);

  if (!_line) return;
  if (_lineJump) return;

  ProfileCostArray* lineCost = _lineCall ? (ProfileCostArray*)_lineCall : (ProfileCostArray*)_line;

  // do not show any cost inside of cycles
  if (_lineCall &&
      ((_lineCall->call()->inCycle()>0) ||
       (_lineCall->call()->isRecursion()))) {
    QString str;
    QPixmap p;

    QString icon = "edit-undo";
#if 0 // TODO
    KIconLoader* loader = KIconLoader::global();
    p= loader->loadIcon(icon, KIconLoader::Small, 0,
                        KIconLoader::DefaultState, QStringList(), 0, true);
#endif
    if (p.isNull())
      str = QObject::tr("(cycle)");

    setText(1, str);
    setIcon(1, p);
    setText(2, str);
    setIcon(2, p);
    return;
  }

  ProfileCostArray* totalCost;
  if (GlobalConfig::showExpanded())
    totalCost = _line->functionSource()->function()->inclusive();
  else
    totalCost = _line->functionSource()->function()->data();

  EventType* ct = _view->eventType();
  _pure = ct ? lineCost->subCost(ct) : SubCost(0);
  if (_pure == 0) {
    setText(1, QString());
    setIcon(1, QPixmap());
  }
  else {
    double total = totalCost->subCost(ct);
    double pure  = 100.0 * _pure / total;

    if (GlobalConfig::showPercentage())
      setText(1, QString("%1")
	      .arg(pure, 0, 'f', GlobalConfig::percentPrecision()));
    else
      setText(1, _pure.pretty());

    setIcon(1, costPixmap(ct, lineCost, total, false));
  }

  EventType* ct2 = _view->eventType2();
  _pure2 = ct2 ? lineCost->subCost(ct2) : SubCost(0);
  if (_pure2 == 0) {
    setText(2, QString());
    setIcon(2, QPixmap());
  }
  else {
    double total = totalCost->subCost(ct2);
    double pure2  = 100.0 * _pure2 / total;

    if (GlobalConfig::showPercentage())
      setText(2, QString("%1")
	      .arg(pure2, 0, 'f', GlobalConfig::percentPrecision()));
    else
      setText(2, _pure2.pretty());

    setIcon(2, costPixmap(ct2, lineCost, total, false));
  }
}
Beispiel #6
0
void CostTypeItem::update()
{
  TraceData* d = _costItem ? _costItem->data() : 0;
  double total = d ? ((double)d->subCost(_costType)) : 0.0;

  if (total == 0.0) {
    setText(1, "-");
    setPixmap(1, QPixmap());
    setText(2, "-");
    setPixmap(2, QPixmap());
    return;
  }

  TraceFunction* f = (_costItem->type()==TraceCost::Function) ?
                     (TraceFunction*)_costItem : 0;

  TraceCost* selfTotalCost = f ? f->data() : d;
  if (f && Configuration::showExpanded()) {
      switch(_groupType) {
      case TraceCost::Object: selfTotalCost = f->object(); break;
      case TraceCost::Class:  selfTotalCost = f->cls(); break;
      case TraceCost::File:   selfTotalCost = f->file(); break;
      case TraceCost::FunctionCycle: selfTotalCost = f->cycle(); break;
      default: break;
      }
  }
  if (_costItem->type()==TraceCost::FunctionCycle) {
      f = (TraceFunction*)_costItem;
      selfTotalCost = f->data();
  }

  double selfTotal = selfTotalCost->subCost(_costType);

  // for all cost items there's a self cost
  _pure = _costItem ? _costItem->subCost(_costType) : SubCost(0);
  double pure  = 100.0 * _pure / selfTotal;
  if (Configuration::showPercentage()) {
    setText(2, QString("%1")
            .arg(pure, 0, 'f', Configuration::percentPrecision()));
  }
  else
    setText(2, _costItem->prettySubCost(_costType));

  setPixmap(2, costPixmap(_costType, _costItem, selfTotal, false));

  if (!f) {
    setText(1, "-");
    setPixmap(1, QPixmap());
    return;
  }

  _sum = f->inclusive()->subCost(_costType);
  double sum  = 100.0 * _sum / total;
  if (Configuration::showPercentage()) {
    setText(1, QString("%1")
            .arg(sum, 0, 'f', Configuration::percentPrecision()));
  }
  else
    setText(1, _sum.pretty());

  setPixmap(1, costPixmap(_costType, f->inclusive(), total, false));
}
Beispiel #7
0
void EventTypeItem::update()
{
    TraceData* d = _costItem ? _costItem->data() : 0;
    double total = d ? ((double)d->subCost(_eventType)) : 0.0;

    if (total == 0.0) {
        setText(1, "-");
        setIcon(1, QIcon());
        setText(2, "-");
        setIcon(2, QIcon());
        return;
    }

    TraceFunction* f = (_costItem && _costItem->type()==ProfileContext::Function) ?
                       (TraceFunction*)_costItem : 0;

    ProfileCostArray* selfTotalCost = f ? f->data() : d;
    if (f && GlobalConfig::showExpanded()) {
        ProfileCostArray* parent = 0;
        switch(_groupType) {
        case ProfileContext::Object:
            parent = f->object();
            break;
        case ProfileContext::Class:
            parent = f->cls();
            break;
        case ProfileContext::File:
            parent = f->file();
            break;
        case ProfileContext::FunctionCycle:
            parent = f->cycle();
            break;
        default:
            break;
        }
        if (parent) selfTotalCost = parent;
    }
    if (_costItem && _costItem->type()==ProfileContext::FunctionCycle) {
        f = (TraceFunction*)_costItem;
        selfTotalCost = f->data();
    }

    double selfTotal = selfTotalCost->subCost(_eventType);

    // for all cost items there is a self cost
    _pure = _costItem ? _costItem->subCost(_eventType) : SubCost(0);
    double pure  = 100.0 * _pure / selfTotal;
    if (GlobalConfig::showPercentage()) {
        setText(2, QString("%1")
                .arg(pure, 0, 'f', GlobalConfig::percentPrecision()));
    }
    else if (_costItem)
        setText(2, _costItem->prettySubCost(_eventType));

    setIcon(2, QIcon(costPixmap(_eventType, _costItem, selfTotal, false)));

    if (!f) {
        setText(1, "-");
        setIcon(1, QIcon());
        return;
    }

    _sum = f->inclusive()->subCost(_eventType);
    double sum  = 100.0 * _sum / total;
    if (GlobalConfig::showPercentage()) {
        setText(1, QString("%1")
                .arg(sum, 0, 'f', GlobalConfig::percentPrecision()));
    }
    else
        setText(1, _sum.pretty());

    setIcon(1, QIcon(costPixmap(_eventType, f->inclusive(), total, false)));
}
Beispiel #8
0
void InstrItem::updateCost()
{
    _pure = SubCost(0);
    _pure2 = SubCost(0);

    if (!_instr) return;
    if (_instrJump) return;

    ProfileCostArray* instrCost = _instrCall ?
                                      (ProfileCostArray*)_instrCall : (ProfileCostArray*)_instr;

    // do not show any cost inside of cycles
    if (_instrCall &&
        ((_instrCall->call()->inCycle()>0) ||
         (_instrCall->call()->isRecursion()))) {
        QString str;
        QPixmap p;

        QFontMetrics fm(font(1));
        p = QIcon::fromTheme(QStringLiteral("edit-undo")).pixmap(fm.height());
        if (p.isNull())
            str = QObject::tr("(cycle)");

        setText(1, str);
        setIcon(1, p);
        setText(2, str);
        setIcon(2, p);
        return;
    }

    ProfileCostArray* totalCost;
    if (GlobalConfig::showExpanded())
        totalCost = _instr->function()->inclusive();
    else
        totalCost = _instr->function()->data();

    EventType *et = _view->eventType();
    _pure = et ? instrCost->subCost(et) : SubCost(0);
    if (_pure == 0) {
        setText(1, QString());
        setIcon(1, QPixmap());
    }
    else {
        double total = totalCost->subCost(et);
        double pure  = 100.0 * _pure / total;

        if (GlobalConfig::showPercentage())
            setText(1, QStringLiteral("%1")
                    .arg(pure, 0, 'f', GlobalConfig::percentPrecision()));
        else
            setText(1, _pure.pretty());

        setIcon(1, costPixmap(et, instrCost, total, false));
    }

    EventType *ct2 = _view->eventType2();
    _pure2 = ct2 ? instrCost->subCost(ct2) : SubCost(0);
    if (_pure2 == 0) {
        setText(2, QString());
        setIcon(2, QPixmap());
    }
    else {
        double total = totalCost->subCost(ct2);
        double pure  = 100.0 * _pure2 / total;

        if (GlobalConfig::showPercentage())
            setText(2, QStringLiteral("%1")
                    .arg(pure, 0, 'f', GlobalConfig::percentPrecision()));
        else
            setText(2, _pure2.pretty());

        setIcon(2, costPixmap(ct2, instrCost, total, false));
    }
}
Beispiel #9
0
void CalleeCoverageItem::update()
{
  if (!_coverage) {
    setText(0, QString::null);
    setText(1, QString::null);
    setText(2, QString::null);
    return;
  }

  _pSum = 100.0 * _coverage->inclusive();

  // pSum/pSelf are percentages of inclusive cost of base
  SubCost realSum = _base->inclusive()->subCost(_costType);
  _sum = SubCost(realSum * _coverage->inclusive());


  QString str;
  if (Configuration::showPercentage())
    str = QString("%1").arg(_pSum, 0, 'f', Configuration::percentPrecision());
  else
    str = _sum.pretty();

  if (_skipped) {
    str = QString("< %1").arg(str);
    setText(0, str);
    setText(1, str);
    return;
  }
 setText(0, str);

 _pSelf = 100.0 * _coverage->self();
 _self = SubCost(realSum * _coverage->self());

 if (Configuration::showPercentage()) {
    setText(1, QString("%1")
            .arg(_pSelf, 0, 'f', Configuration::percentPrecision()));
  }
  else {
    setText(1, _self.pretty());
  }

  setPixmap(0, partitionPixmap(25, 10, _coverage->inclusiveHistogram(), 0,
                               Coverage::maxHistogramDepth, false));
  setPixmap(1, partitionPixmap(25, 10, _coverage->selfHistogram(), 0,
                               Coverage::maxHistogramDepth, false));


  _cc  = SubCost(_coverage->callCount());
  setText(3, _cc ? _cc.pretty() : QString("(0)"));

  // for comparations
  _distance = _coverage->inclusiveMedian();
  QString distString;
  if (_coverage->minDistance() == _coverage->maxDistance())
    distString = QString::number(_distance);
  else {
    int sMed = _coverage->selfMedian();
    QString med;
    if (_distance == sMed)
      med = QString::number(_distance);
    else
      med = QString("%1/%2").arg(_distance).arg(sMed);

    distString = QString("%1-%2 (%3)")
                 .arg(_coverage->minDistance())
                 .arg(_coverage->maxDistance())
                 .arg(med);
  }
  setText(2, distString);
}