1 /*
2 * Copyright (C) 2024 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 #include "src/trace_processor/importers/perf/perf_counter.h"
18
19 #include <cstdint>
20
21 #include "perfetto/base/logging.h"
22 #include "src/trace_processor/tables/counter_tables_py.h"
23
24 namespace perfetto::trace_processor::perf_importer {
25
AddDelta(int64_t ts,double delta)26 void PerfCounter::AddDelta(int64_t ts, double delta) {
27 last_count_ += delta;
28 counter_table_.Insert({ts, track_id_, last_count_});
29 }
30
AddCount(int64_t ts,double count)31 void PerfCounter::AddCount(int64_t ts, double count) {
32 PERFETTO_CHECK(count >= last_count_);
33 last_count_ = count;
34 counter_table_.Insert({ts, track_id_, last_count_});
35 }
36
37 } // namespace perfetto::trace_processor::perf_importer
38