5 #include <linux/time64.h> 17 u64 time_sec, time_nsec;
20 time_sec = strtoul(str, &end, 10);
21 if (*end !=
'.' && *end !=
'\0')
28 if (strlen(++end) > 9)
31 strncpy(nsec_buf, end, 9);
35 for (i = strlen(nsec_buf); i < 9; i++)
38 time_nsec = strtoul(nsec_buf, &end, 10);
49 char *start_str,
char *end_str)
51 if (start_str && (*start_str !=
'\0') &&
56 if (end_str && (*end_str !=
'\0') &&
66 char *start_str, *end_str;
69 if (ostr == NULL || *ostr ==
'\0')
78 d = strchr(start_str, ch);
93 char *start_str = NULL, *end_str;
108 if (rc == 0 && ptime->
end && ptime->
end < ptime->
start)
122 c = strchr(str,
'%');
128 d = strtod(str, &endptr);
129 if (endptr != str + strlen(str))
140 double pcnt, start_pcnt, end_pcnt;
141 u64 total = end -
start;
150 p = strchr(str,
'/');
159 i = (int)strtol(p, &end_str, 10);
166 start_pcnt = pcnt * (i - 1);
169 if (start_pcnt < 0.0 || start_pcnt > 1.0 ||
170 end_pcnt < 0.0 || end_pcnt > 1.0) {
174 ptime->
start = start + round(start_pcnt * total);
175 ptime->
end = start + round(end_pcnt * total);
183 char *start_str = NULL, *end_str;
184 double start_pcnt, end_pcnt;
185 u64 total = end -
start;
193 if (ret || !start_str)
204 if (start_pcnt < 0.0 || start_pcnt > 1.0 ||
205 end_pcnt < 0.0 || end_pcnt > 1.0 ||
206 start_pcnt > end_pcnt) {
210 ptime->
start = start + round(start_pcnt * total);
211 ptime->
end = start + round(end_pcnt * total);
220 const char *ostr, u64
start, u64
end,
233 while (p1 < str + len) {
239 p2 = strchr(p1,
',');
243 ret = (
func)(p1, &ptime_buf[i], start, end);
249 pr_debug(
"start time %d: %" PRIu64
", ", i, ptime_buf[i].start);
250 pr_debug(
"end time %d: %" PRIu64
"\n", i, ptime_buf[i].end);
265 const char *ostr, u64
start, u64
end,
char *c)
268 int len = strlen(ostr), ret;
274 if (ostr + len - 1 != c)
285 strcpy(str + len,
"/1");
296 const char *ostr, u64
start, u64
end)
307 memset(ptime_buf, 0,
sizeof(*ptime_buf) * num);
309 c = strchr(ostr,
'/');
315 c = strchr(ostr,
'-');
321 c = strchr(ostr,
'%');
341 while (p1 < ostr + strlen(ostr)) {
342 p2 = strchr(p1,
',');
352 ptime = calloc(i,
sizeof(*ptime));
363 if ((ptime->
start && timestamp < ptime->
start) ||
364 (ptime->
end && timestamp > ptime->
end)) {
372 int num, u64 timestamp)
377 if ((timestamp == 0) || (num == 0))
386 for (i = 0; i < num; i++) {
387 ptime = &ptime_buf[i];
389 if (timestamp >= ptime->
start &&
390 ((timestamp < ptime->
end && i < num - 1) ||
391 (timestamp <= ptime->
end && i == num - 1))) {
396 return (i == num) ? true :
false;
404 return scnprintf(buf, sz,
"%"PRIu64
".%06"PRIu64, sec, usec);
413 if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm))
416 if (!strftime(dt,
sizeof(dt),
"%Y%m%d%H%M%S", &tm))
419 scnprintf(buf, sz,
"%s%02u", dt, (
unsigned)tv.tv_usec / 10000);
static int one_percent_convert(struct perf_time_interval *ptime_buf, const char *ostr, u64 start, u64 end, char *c)
static int parse_percent(double *pcnt, char *str)
static struct perf_time_interval ptime
int parse_nsec_time(const char *str, u64 *ptime)
static int percent_comma_split(struct perf_time_interval *ptime_buf, int num, const char *ostr, u64 start, u64 end, time_pecent_split func)
struct perf_time_interval * perf_time__range_alloc(const char *ostr, int *size)
int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz)
bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp)
int(* time_pecent_split)(char *, struct perf_time_interval *, u64 start, u64 end)
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
bool perf_time__ranges_skip_sample(struct perf_time_interval *ptime_buf, int num, u64 timestamp)
#define pr_debug(fmt,...)
static int str(yyscan_t scanner, int token)
int fetch_current_timestamp(char *buf, size_t sz)
static int parse_timestr_sec_nsec(struct perf_time_interval *ptime, char *start_str, char *end_str)
static int percent_dash_split(char *str, struct perf_time_interval *ptime, u64 start, u64 end)
x86 movsq based memcpy() in arch/x86/lib/memcpy_64.S") MEMCPY_FN(memcpy_erms
static int split_start_end(char **start, char **end, const char *ostr, char ch)
int perf_time__percent_parse_str(struct perf_time_interval *ptime_buf, int num, const char *ostr, u64 start, u64 end)
static int percent_slash_split(char *str, struct perf_time_interval *ptime, u64 start, u64 end)
int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr)