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_TRANSACTION_INFO_HPP
20 #define REALM_TRANSACTION_INFO_HPP
25 #include <realm/metrics/metric_timer.hpp>
26 #include <realm/util/features.h>
35 class TransactionInfo {
37 enum TransactionType {
41 TransactionInfo(TransactionType type);
42 TransactionInfo(const TransactionInfo&) = default;
43 ~TransactionInfo() noexcept;
45 TransactionType get_transaction_type() const;
46 // the transaction time is a total amount which includes fsync_time + write_time + user_time
47 double get_transaction_time() const;
48 double get_fsync_time() const;
49 double get_write_time() const;
50 size_t get_disk_size() const;
51 size_t get_free_space() const;
52 size_t get_total_objects() const;
53 size_t get_num_available_versions() const;
56 MetricTimerResult m_transaction_time;
57 std::shared_ptr<MetricTimerResult> m_fsync_time;
58 std::shared_ptr<MetricTimerResult> m_write_time;
59 MetricTimer m_transact_timer;
61 size_t m_realm_disk_size;
62 size_t m_realm_free_space;
63 size_t m_total_objects;
64 TransactionType m_type;
65 size_t m_num_versions;
68 void update_stats(size_t disk_size, size_t free_space, size_t total_objects, size_t available_versions);
72 } // namespace metrics
75 #endif // REALM_METRICS
77 #endif // REALM_TRANSACTION_INFO_HPP