2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2016-11-29 10:15:41 -07:00
|
|
|
#ifndef _TIME_UTILS_H_
|
|
|
|
|
#define _TIME_UTILS_H_
|
|
|
|
|
|
2017-04-19 16:12:39 -03:00
|
|
|
#include <stddef.h>
|
2019-08-29 15:16:27 -03:00
|
|
|
#include <time.h>
|
2017-04-19 16:12:39 -03:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
2016-11-29 10:15:41 -07:00
|
|
|
struct perf_time_interval {
|
|
|
|
|
u64 start, end;
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-29 10:15:42 -07:00
|
|
|
int parse_nsec_time(const char *str, u64 *ptime);
|
|
|
|
|
|
2016-11-29 10:15:41 -07:00
|
|
|
int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr);
|
|
|
|
|
|
2017-12-08 21:13:43 +08:00
|
|
|
int perf_time__percent_parse_str(struct perf_time_interval *ptime_buf, int num,
|
|
|
|
|
const char *ostr, u64 start, u64 end);
|
|
|
|
|
|
2018-01-10 23:00:31 +08:00
|
|
|
struct perf_time_interval *perf_time__range_alloc(const char *ostr, int *size);
|
|
|
|
|
|
2016-11-29 10:15:41 -07:00
|
|
|
bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp);
|
|
|
|
|
|
2017-12-08 21:13:44 +08:00
|
|
|
bool perf_time__ranges_skip_sample(struct perf_time_interval *ptime_buf,
|
|
|
|
|
int num, u64 timestamp);
|
|
|
|
|
|
2019-03-01 18:13:06 +08:00
|
|
|
struct perf_session;
|
|
|
|
|
|
2019-10-11 11:21:39 -07:00
|
|
|
int perf_time__parse_for_ranges_reltime(const char *str, struct perf_session *session,
|
|
|
|
|
struct perf_time_interval **ranges,
|
|
|
|
|
int *range_size, int *range_num,
|
|
|
|
|
bool reltime);
|
|
|
|
|
|
2019-03-01 18:13:06 +08:00
|
|
|
int perf_time__parse_for_ranges(const char *str, struct perf_session *session,
|
|
|
|
|
struct perf_time_interval **ranges,
|
|
|
|
|
int *range_size, int *range_num);
|
|
|
|
|
|
2017-04-19 16:12:39 -03:00
|
|
|
int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz);
|
2019-03-05 06:47:53 -08:00
|
|
|
int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz);
|
2017-04-19 16:12:39 -03:00
|
|
|
|
|
|
|
|
int fetch_current_timestamp(char *buf, size_t sz);
|
|
|
|
|
|
2019-08-29 15:16:27 -03:00
|
|
|
static inline unsigned long long rdclock(void)
|
|
|
|
|
{
|
|
|
|
|
struct timespec ts;
|
|
|
|
|
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
|
|
|
return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-29 10:15:41 -07:00
|
|
|
#endif
|