public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Andi Kleen <andi@firstfloor.org>,
	Jiri Olsa <jolsa@redhat.com>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v2 1/4] perf util: Add parse_nsec_time() function
Date: Thu, 04 Jul 2013 16:45:42 +0900	[thread overview]
Message-ID: <87li5mzs2h.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1370234653-31582-1-git-send-email-namhyung@kernel.org> (Namhyung Kim's message of "Mon, 3 Jun 2013 13:44:10 +0900")

Hi Arnaldo,

Could you pick these up or give a comment?

Thanks,
Namhyung


On Mon,  3 Jun 2013 13:44:10 +0900, Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@lge.com>
>
> The parse_nsec_time() function is for parsing a string of time into
> 64-bit nsec value.  It's a preparation of time filtering in some of
> perf commands.
>
> Cc: David Ahern <dsahern@gmail.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/util.c | 30 ++++++++++++++++++++++++++++++
>  tools/perf/util/util.h |  2 ++
>  2 files changed, 32 insertions(+)
>
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 59d868add275..4a207c40d7bc 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -269,3 +269,33 @@ void perf_debugfs_set_path(const char *mntpt)
>  	snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt);
>  	set_tracing_events_path(mntpt);
>  }
> +
> +int parse_nsec_time(const char *str, u64 *ptime)
> +{
> +	u64 time_sec, time_nsec;
> +	char *end;
> +
> +	time_sec = strtoul(str, &end, 10);
> +	if (*end != '.' && *end != '\0')
> +		return -1;
> +
> +	if (*end == '.') {
> +		int i;
> +		char nsec_buf[10];
> +
> +		strncpy(nsec_buf, end + 1, 9);
> +		nsec_buf[9] = '\0';
> +
> +		/* make it nsec precision */
> +		for (i = strlen(nsec_buf); i < 9; i++)
> +			nsec_buf[i] = '0';
> +
> +		time_nsec = strtoul(nsec_buf, &end, 10);
> +		if (*end != '\0')
> +			return -1;
> +	} else
> +		time_nsec = 0;
> +
> +	*ptime = time_sec * NSEC_PER_SEC + time_nsec;
> +	return 0;
> +}
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 7a484c97e500..6c8baf312c8a 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -204,6 +204,8 @@ static inline int has_extension(const char *filename, const char *ext)
>  #define NSEC_PER_MSEC	1000000L
>  #endif
>  
> +int parse_nsec_time(const char *str, u64 *ptime);
> +
>  extern unsigned char sane_ctype[256];
>  #define GIT_SPACE		0x01
>  #define GIT_DIGIT		0x02

      parent reply	other threads:[~2013-07-04  7:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-03  4:44 [PATCH v2 1/4] perf util: Add parse_nsec_time() function Namhyung Kim
2013-06-03  4:44 ` [PATCH v2 2/4] perf script: Add --time-filter option Namhyung Kim
2013-06-06  1:32   ` David Ahern
2013-06-03  4:44 ` [PATCH v2 3/4] perf report: " Namhyung Kim
2013-06-06  1:33   ` David Ahern
2013-06-03  4:44 ` [PATCH/RFC v2 4/4] perf inject: " Namhyung Kim
2013-06-03 15:46 ` [PATCH v2 1/4] perf util: Add parse_nsec_time() function David Ahern
2013-06-04  1:50   ` [PATCH v3 " Namhyung Kim
2013-06-06  1:31     ` David Ahern
2013-08-12 10:18     ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-07-04  7:45 ` Namhyung Kim [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87li5mzs2h.fsf@sejong.aot.lge.com \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox