DPDK usage discussions
 help / color / Atom feed
* [dpdk-users] How to get the current timestamp in milliseconds in the DPDK?
@ 2019-11-12  8:40 Gokul Bargaje
  2019-11-12  9:47 ` 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-users] How to get the current timestamp in milliseconds in the DPDK?
  2019-11-12  8:40 [dpdk-users] 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, back to index

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-users] How to get the current timestamp in milliseconds in the DPDK? Gokul Bargaje
2019-11-12  9:47 ` Archit Pandey

DPDK usage discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/users/0 users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 users users/ http://inbox.dpdk.org/users \
		users@dpdk.org
	public-inbox-index users


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox