callchain.h revision ecb9a302b52b034610efb85bd73cb473e7c4ddb2
1ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui/* 2ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * Copyright (C) 2015 The Android Open Source Project 3ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * 4ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * Licensed under the Apache License, Version 2.0 (the "License"); 5ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * you may not use this file except in compliance with the License. 6ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * You may obtain a copy of the License at 7ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * 8ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * http://www.apache.org/licenses/LICENSE-2.0 9ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * 10ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * Unless required by applicable law or agreed to in writing, software 11ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * distributed under the License is distributed on an "AS IS" BASIS, 12ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * See the License for the specific language governing permissions and 14ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui * limitations under the License. 15ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui */ 16ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui 17ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui#ifndef SIMPLE_PERF_CALLCHAIN_H_ 18ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui#define SIMPLE_PERF_CALLCHAIN_H_ 19ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui 20ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui#include <memory> 21ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui#include <vector> 22ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui 23ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cuistruct SampleEntry; 24ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui 25ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cuistruct CallChainNode { 26ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui uint64_t period; 27ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui uint64_t children_period; 28ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui std::vector<SampleEntry*> chain; 29ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui std::vector<std::unique_ptr<CallChainNode>> children; 30ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui}; 31ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui 32ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cuistruct CallChainRoot { 33ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui uint64_t children_period; 34ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui std::vector<std::unique_ptr<CallChainNode>> children; 35ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui 36ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui CallChainRoot() : children_period(0) { 37ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui } 38ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui 39ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui void AddCallChain(const std::vector<SampleEntry*>& callchain, uint64_t period); 40ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui void SortByPeriod(); 41ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui}; 42ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui 43ecb9a302b52b034610efb85bd73cb473e7c4ddb2Yabin Cui#endif // SIMPLE_PERF_CALLCHAIN_H_ 44