1 /*************************************************************************
3 * Copyright 2016 Realm Inc.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 **************************************************************************/
19 #ifndef REALM_METRICS_HPP
20 #define REALM_METRICS_HPP
25 #include <realm/metrics/query_info.hpp>
26 #include <realm/metrics/transaction_info.hpp>
27 #include <realm/util/features.h>
41 size_t num_query_metrics() const;
42 size_t num_transaction_metrics() const;
44 void add_query(QueryInfo info);
45 void add_transaction(TransactionInfo info);
47 void start_read_transaction();
48 void start_write_transaction();
49 void end_read_transaction(size_t total_size, size_t free_space, size_t num_objects, size_t num_versions);
50 void end_write_transaction(size_t total_size, size_t free_space, size_t num_objects, size_t num_versions);
51 static std::unique_ptr<MetricTimer> report_fsync_time(const Group& g);
52 static std::unique_ptr<MetricTimer> report_write_time(const Group& g);
54 using QueryInfoList = std::vector<QueryInfo>;
55 using TransactionInfoList = std::vector<TransactionInfo>;
57 // Get the list of metric objects tracked since the last take
58 std::unique_ptr<QueryInfoList> take_queries();
59 std::unique_ptr<TransactionInfoList> take_transactions();
61 std::unique_ptr<QueryInfoList> m_query_info;
62 std::unique_ptr<TransactionInfoList> m_transaction_info;
64 std::unique_ptr<TransactionInfo> m_pending_read;
65 std::unique_ptr<TransactionInfo> m_pending_write;
75 #endif // REALM_METRICS
77 } // namespace metrics
82 #endif // REALM_METRICS_HPP