DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] How to get the current timestamp in milliseconds in the DPDK?
@ 2019-11-12  8:40 Gokul Bargaje
  2019-11-12  9:47 ` [dpdk-dev] [dpdk-users] " Archit Pandey
  0 siblings, 1 reply; 2+ messages in thread
From: Gokul Bargaje @ 2019-11-12  8:40 UTC (permalink / raw)
  To: users, dev

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [dpdk-users] How to get the current timestamp in milliseconds in the DPDK?
  2019-11-12  8:40 [dpdk-dev] How to get the current timestamp in milliseconds in the DPDK? Gokul Bargaje
@ 2019-11-12  9:47 ` Archit Pandey
  0 siblings, 0 replies; 2+ messages in thread
From: Archit Pandey @ 2019-11-12  9:47 UTC (permalink / raw)
  To: Gokul Bargaje, users, dev, Mohit P. Tahiliani

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-12  9:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12  8:40 [dpdk-dev] How to get the current timestamp in milliseconds in the DPDK? Gokul Bargaje
2019-11-12  9:47 ` [dpdk-dev] [dpdk-users] " Archit Pandey

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).