2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.1 (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
8 * http://floralicense.org/license/
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.
21 * @brief System's statistics snapshot
25 unsigned long long busy_ticks;
26 unsigned long long total_ticks;
30 * @brief Process's statistics snapshot
34 unsigned long long system_ticks;
35 unsigned long long process_ticks;
39 * @brief Initializes stats module.
41 * @return: 0 on success, other value on error.
43 * @note function should be called before any other function call from this
49 * @brief Calculates average cpu usage between two stats snapshots.
51 * @param[in] previous the stats snapshots taken before current
52 * @param[in] current the stats snapshots taken after previous
53 * @param[out] usage the cpu usage as percent.
55 * @return: 0 on success, other value on error
57 int stats_get_system_cpu_usage_average(struct stats_system *previous, struct stats_system *current, float *usage);
60 * @brief Takes system statistics snapshot.
62 * @param[out] stats System's statistics snapshot.
64 * @return: 0 on success, other value on error
66 int stats_update_system_stats(struct stats_system *stats);
69 * @brief Calculates system memory usage.
71 * @param[out] usage the memory usage as percent.
73 * @return: 0 on success, other value on error
75 int stats_get_system_memory_usage(float *usage);
78 * @brief Takes process statistics snapshot.
80 * @param[in] pid the process id.
81 * @param[out] stats process statistcs.
83 * @return: 0 on success, other value on error
85 int stats_update_process_stats(int pid, struct stats_process *stats);
88 * @brief Calculates average process cpu usage between two stats snapshots.
90 * @param[in] previous the stats snapshots taken before current
91 * @param[in] current the stats snapshots taken after previous
92 * @param[out] usage the cpu usage as percent. It may be greater then 100% in
93 * case of multithreaded applications.
95 * @note in case when process has 2 threads which runs tight loop, the function
96 * will report 200% usage.
98 * @return: 0 on success, other value on error
100 int stats_get_process_cpu_usage_average(struct stats_process *previous, struct stats_process *current, float *usage);
103 * @brief Calculates process memory usage.
105 * @param[in] pid the process id.
106 * @param[out] usage process memory usage.
108 * @return: 0 on success, other value on error
110 int stats_get_process_memory_usage(int pid, float *usage);
113 * @brief Gets system load averages stats.
115 * @param[out] a1 one minute average.
116 * @param[out] a5 five minute average.
117 * @param[out] a15 fifteen minute average.
119 * @return: 0 on success, other value on error
121 int stats_get_load_averages(float *a1, float *a5, float *a15);