1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_EXPERIMENTAL_COUNTER_DUR_H_ 18 #define SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_EXPERIMENTAL_COUNTER_DUR_H_ 19 20 #include <cstdint> 21 #include <memory> 22 #include <string> 23 #include <vector> 24 25 #include "perfetto/ext/base/status_or.h" 26 #include "perfetto/trace_processor/basic_types.h" 27 #include "src/trace_processor/db/column_storage.h" 28 #include "src/trace_processor/db/table.h" 29 #include "src/trace_processor/perfetto_sql/intrinsics/table_functions/static_table_function.h" 30 #include "src/trace_processor/tables/counter_tables_py.h" 31 32 namespace perfetto::trace_processor { 33 34 class ExperimentalCounterDur : public StaticTableFunction { 35 public: 36 using CounterTable = tables::CounterTable; 37 38 explicit ExperimentalCounterDur(const CounterTable& table); 39 virtual ~ExperimentalCounterDur() override; 40 41 Table::Schema CreateSchema() override; 42 std::string TableName() override; 43 uint32_t EstimateRowCount() override; 44 base::StatusOr<std::unique_ptr<Table>> ComputeTable( 45 const std::vector<SqlValue>& arguments) override; 46 47 // public + static for testing 48 static ColumnStorage<int64_t> ComputeDurColumn(const CounterTable& table); 49 static ColumnStorage<double> ComputeDeltaColumn(const CounterTable& table); 50 51 private: 52 const CounterTable* counter_table_ = nullptr; 53 std::unique_ptr<Table> counter_dur_table_; 54 }; 55 56 } // namespace perfetto::trace_processor 57 58 #endif // SRC_TRACE_PROCESSOR_PERFETTO_SQL_INTRINSICS_TABLE_FUNCTIONS_EXPERIMENTAL_COUNTER_DUR_H_ 59