Appends a copy of the timing traces to the provided array and optionally removes the first n elements. Pass a nullptr to only remove elements without copying them. This is useful to first get the traces and in a second call remove those that are no longer needed. Returns number appended or removed.