linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Yordan Karadzhov <ykaradzhov@vmware.com>
Cc: linux-trace-devel@vger.kernel.org,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: Re: [PATCH v2 2/5] kernel-shark-qt: Add kshark_convert_nano() function
Date: Tue, 2 Oct 2018 17:09:40 -0400	[thread overview]
Message-ID: <20181002170940.6261fd8a@gandalf.local.home> (raw)
In-Reply-To: <20181001135921.32379-3-ykaradzhov@vmware.com>

On Mon,  1 Oct 2018 16:59:18 +0300
Yordan Karadzhov <ykaradzhov@vmware.com> wrote:

> From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
> 
> kshark_convert_nano() is used to convert the original value of the
> timestamp of the trace records (having nanosecond precision) into two
> values representing the time in seconds and milliseconds.
> 
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> ---
>  kernel-shark-qt/src/libkshark.c | 14 ++++++++++++++
>  kernel-shark-qt/src/libkshark.h |  2 ++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/kernel-shark-qt/src/libkshark.c b/kernel-shark-qt/src/libkshark.c
> index a7983eb..e7ea007 100644
> --- a/kernel-shark-qt/src/libkshark.c
> +++ b/kernel-shark-qt/src/libkshark.c
> @@ -1073,6 +1073,20 @@ const char *kshark_get_info_easy(struct kshark_entry *entry)
>  	return info;
>  }
>  
> +/**
> + * @brief Convert the timestamp of the trace record (nanosecond precision) into
> + *	  seconds and microseconds.
> + *
> + * @param time: Input location for the timestamp.
> + * @param sec: Output location for the value of the seconds.
> + * @param usec: Output location for the value of the microseconds.
> + */
> +void kshark_convert_nano(uint64_t time, uint64_t *sec, uint64_t *usec)
> +{
> +	*sec = time / 1000000000ULL;
> +	*usec = (time / 1000) % 1000000;

BTW, just a little optimization, as '%' and '/' are very expensive
operations, you can remove one by this:

{
	uint64_t s;

	s = time / 1000000000ULL;
	*sec = s;
	*usec = (time - s * 1000000000ULL) / 1000;

As '-' and '*' are fast operations.

-- Steve

> +}
> +
>  /**
>   * @brief Dump into a string the content of one entry. The function allocates
>   *	  a null terminated string and returns a pointer to this string. The
> diff --git a/kernel-shark-qt/src/libkshark.h b/kernel-shark-qt/src/libkshark.h
> index f00a584..d24ed8c 100644
> --- a/kernel-shark-qt/src/libkshark.h
> +++ b/kernel-shark-qt/src/libkshark.h
> @@ -160,6 +160,8 @@ const char *kshark_get_event_name_easy(struct kshark_entry *entry);
>  
>  const char *kshark_get_info_easy(struct kshark_entry *entry);
>  
> +void kshark_convert_nano(uint64_t time, uint64_t *sec, uint64_t *usec);
> +
>  char* kshark_dump_entry(const struct kshark_entry *entry);
>  
>  struct tep_record *kshark_read_at(struct kshark_context *kshark_ctx,

  reply	other threads:[~2018-10-03  3:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-01 13:59 [PATCH v2 0/5] Final preparation before adding the KernelShark GUI Yordan Karadzhov
2018-10-01 13:59 ` [PATCH v2 1/5] kernel-shark-qt: Add kshark_get_X_easy() functions Yordan Karadzhov
2018-10-02 20:44   ` Steven Rostedt
2018-10-03  7:34     ` Yordan Karadzhov
2018-10-05 14:30       ` Yordan Karadzhov (VMware)
2018-10-05 14:46         ` Steven Rostedt
2018-10-05 15:27           ` Yordan Karadzhov (VMware)
2018-10-05 15:44             ` Steven Rostedt
2018-10-01 13:59 ` [PATCH v2 2/5] kernel-shark-qt: Add kshark_convert_nano() function Yordan Karadzhov
2018-10-02 21:09   ` Steven Rostedt [this message]
2018-10-01 13:59 ` [PATCH v2 3/5] kernel-shark-qt: Add functions for fast clearing of the filters Yordan Karadzhov
2018-10-01 13:59 ` [PATCH v2 4/5] kernel-shark-qt: Rename the Cmake-generated header file Yordan Karadzhov
2018-10-01 13:59 ` [PATCH v2 5/5] kernel-shark-qt: Fix a bug in kshark_data_collection_alloc() Yordan Karadzhov
2018-10-02 21:18   ` Steven Rostedt

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=20181002170940.6261fd8a@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=y.karadz@gmail.com \
    --cc=ykaradzhov@vmware.com \
    /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;
as well as URLs for NNTP newsgroup(s).