summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ec8f5a6)
The FastCallSet supports only ranges step of 1 and freq of
FREQUENCY_ALL, so store any such ranges there, and store all other
ranges in the existing, linear list of CallRange.
For manually entered call sets on the command line, the performance
hit of the linear lookup was not generally a problem. But when taking
the (potentially huge) output of "apitrace trim --print-callset" the
performance hit made things quite painful. This makes things usable
again.
#include <trace_callset.hpp>
#include <trace_callset.hpp>
#include <list>
#include "trace_model.hpp"
#include <list>
#include "trace_model.hpp"
+#include "trace_fast_callset.hpp"
CallRange limits;
public:
CallRange limits;
public:
- // TODO: use binary tree to speed up lookups
+ FastCallSet fast_call_set;
+
+ // TODO: use binary tree to speed up lookups, (less important
+ // now that we are using FastCallSet for ranges without step
+ // or freq).
typedef std::list< CallRange > RangeList;
RangeList ranges;
typedef std::list< CallRange > RangeList;
RangeList ranges;
// Not empty set
inline bool
empty() const {
// Not empty set
inline bool
empty() const {
+ return fast_call_set.empty() && ranges.empty();
limits.stop = range.stop;
}
limits.stop = range.stop;
}
- RangeList::iterator it = ranges.begin();
- while (it != ranges.end() && it->start < range.start) {
- ++it;
- }
+ /* Optimize by using fast_call_set whenever possible */
+ if (range.step == 1 && range.freq == FREQUENCY_ALL) {
+ fast_call_set.add(range.start, range.stop);
+ } else {
+ RangeList::iterator it = ranges.begin();
+ while (it != ranges.end() && it->start < range.start) {
+ ++it;
+ }
- ranges.insert(it, range);
+ ranges.insert(it, range);
+ }
if (empty()) {
return false;
}
if (empty()) {
return false;
}
+ if (fast_call_set.contains(callNo))
+ return true;
RangeList::const_iterator it;
for (it = ranges.begin(); it != ranges.end() && it->start <= callNo; ++it) {
if (it->contains(callNo, callFlags)) {
RangeList::const_iterator it;
for (it = ranges.begin(); it != ranges.end() && it->start <= callNo; ++it) {
if (it->contains(callNo, callFlags)) {
-FastCallRange::contains(CallNo call_no)
+FastCallRange::contains(CallNo call_no) const
{
return (first <= call_no && last >= call_no);
}
{
return (first <= call_no && last >= call_no);
}
+bool
+FastCallSet::empty(void) const
+{
+ return max_level == 0;
+}
+
FastCallSet::FastCallSet(): head(0, 0, MAX_LEVEL)
{
head.first = std::numeric_limits<CallNo>::max();
FastCallSet::FastCallSet(): head(0, 0, MAX_LEVEL)
{
head.first = std::numeric_limits<CallNo>::max();
-FastCallSet::contains(CallNo call_no)
+FastCallSet::contains(CallNo call_no) const
+ const FastCallRange *node;
FastCallRange(CallNo first, CallNo last, int level);
FastCallRange(CallNo first, CallNo last, int level);
- bool contains(CallNo call_no);
+ bool contains(CallNo call_no) const;
+ bool empty(void) const;
+
void add(CallNo first, CallNo last);
void add(CallNo call_no);
void add(CallNo first, CallNo last);
void add(CallNo call_no);
- bool contains(CallNo call_no);
+ bool contains(CallNo call_no) const;
};
} /* namespace trace */
};
} /* namespace trace */