DPDK patches and discussions
 help / color / mirror / Atom feed
From: Archit Pandey <architpandeynitk@gmail.com>
To: Gokul Bargaje <gokulbargaje.182009@nitk.edu.in>,
	users@dpdk.org, dev@dpdk.org,
	"Mohit P. Tahiliani" <tahiliani@nitk.edu.in>
Subject: Re: [dpdk-dev] [dpdk-users] How to get the current timestamp in milliseconds in the DPDK?
Date: Tue, 12 Nov 2019 15:17:50 +0530	[thread overview]
Message-ID: <13e841db-63b8-9ca7-7e26-0da1ced4bdf2@gmail.com> (raw)
In-Reply-To: <CAH1-=xiqoAoBju70biDGzGTrrVM3BVq7P8mcY+o9xHd7jdhC0Q@mail.gmail.com>

Hi,


DPDK has a function called /rte_get_tsc_cycles() /to get the number of 
CPU cycles since boot. If I'm not wrong, it can be used to calculate 
time elapsed in milliseconds (or any other precision needed).

The following code snippet shows how to calculated time elapsed:

```

uint64_t start = rte_get_tsc_cycles();

<perform operations>

double cpu_time = (double)(rte_get_tsc_cycles() - start) / 
rte_get_tsc_hz(); // gives the time elapsed since start

```

I believe it can be suitably modified to generate timestamps. It'll be 
important to consider what time is taken as 0 while timestamping.


Hope that helps!


Regards,

Archit.
//

On 11/12/2019 2:10 PM, Gokul Bargaje wrote:
> Hi Team,
>
> Like in Java, there is a method called getTimeInMillis() which returns the
> current timestamp in milliseconds. I want to know if there's a way to find
> out timestamp in milliseconds (or in Microseconds) in the C language or in
> the DPDK?
>
> I did some googling and I got the solution which returns the time in
> seconds but I need time in milliseconds.
>
> Thanks,
> Gokul

-- 
Archit Pandey
Senior Year Undergraduate Student
Department of Computer Science and Engineering
National Institute of Technology Karnataka
Surathkal, India


      reply	other threads:[~2019-11-12  9:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12  8:40 [dpdk-dev] " Gokul Bargaje
2019-11-12  9:47 ` Archit Pandey [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=13e841db-63b8-9ca7-7e26-0da1ced4bdf2@gmail.com \
    --to=architpandeynitk@gmail.com \
    --cc=dev@dpdk.org \
    --cc=gokulbargaje.182009@nitk.edu.in \
    --cc=tahiliani@nitk.edu.in \
    --cc=users@dpdk.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;
as well as URLs for NNTP newsgroup(s).