/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
size_t CombinedStacks::AddStack(const Telemetry::ProcessedStack& aStack) {
size_t index = mNextIndex; // Advance the indices of the circular queue holding the stacks.
mNextIndex = (mNextIndex + 1) % mMaxStacksCount; // Grow the vector up to the maximum size, if needed. if (mStacks.size() < mMaxStacksCount) {
mStacks.resize(mStacks.size() + 1);
}
// Clear the old stack before set.
mStacks[index].clear();
size_t stackSize = aStack.GetStackSize(); for (size_t i = 0; i < stackSize; ++i) { // Need to specify a return type in the following lambda, // otherwise it's incorrectly deduced to be a non-reference type.
AddFrame(index, aStack.GetFrame(i),
[&aStack](int aIdx) -> const ProcessedStack::Module& { return aStack.GetModule(aIdx);
});
} return index;
}
for (constauto& stack : aStacks.mStacks) {
size_t index = mNextIndex; // Advance the indices of the circular queue holding the stacks.
mNextIndex = (mNextIndex + 1) % mMaxStacksCount;
// Clear the old stack before set.
mStacks[index].clear();
for (constauto& frame : stack) { // Need to specify a return type in the following lambda, // otherwise it's incorrectly deduced to be a non-reference type.
AddFrame(index, frame,
[&aStacks](int aIdx) -> const ProcessedStack::Module& { return aStacks.mModules[aIdx];
});
}
}
}
size_t CombinedStacks::SizeOfExcludingThis() const { // This is a crude approximation. We would like to do something like // aMallocSizeOf(&mModules[0]), but on linux aMallocSizeOf will call // malloc_usable_size which is only safe on the pointers returned by malloc. // While it works on current libstdc++, it is better to be safe and not assume // that &vec[0] points to one. We could use a custom allocator, but // it doesn't seem worth it.
size_t n = 0;
n += mModules.capacity() * sizeof(Telemetry::ProcessedStack::Module);
n += mStacks.capacity() * sizeof(Stack); for (constauto& s : mStacks) {
n += s.capacity() * sizeof(Telemetry::ProcessedStack::Frame);
} return n;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.