From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7BCACA04AB for ; Tue, 12 Nov 2019 10:47:56 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4C0D72B9D; Tue, 12 Nov 2019 10:47:55 +0100 (CET) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by dpdk.org (Postfix) with ESMTP id 5BE582B96; Tue, 12 Nov 2019 10:47:53 +0100 (CET) Received: by mail-pf1-f181.google.com with SMTP id b19so669678pfd.3; Tue, 12 Nov 2019 01:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:organization:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=yyVY38m0aLPVO3kt/A/1zT0glESgtg5+gpd9k3xbVn8=; b=E0WGv92M66xlJtaJcNMuAdUgBka2uRR4E5bv55orpuzZ81R/zu+jbShNOihaIi8tSP RVKEjLDLG+0FLVExfphWZp/2BImuroBOGJ3MTWclIQLtDaCr94fG/gtGtF0Weuo8z/YK neKuYzeRLwKKB6fD2xmOCQsToGdo4Uqc+CP5kGshqLtLP3VR/+9RiJauuJTH8513fYTd MJ8Bt3Z//4JJ3QdU1fbiO7GA9nQbRrf4WwXaI+SUe4tI6MH6xmb0WN/BsDFLirQQcs1x Bu26oUrsvDeprA6mu27d4TtrxCnKBPsKgOEqe/lBSqY1vl7vklRdOgPnEao9U8y5V+DE Dp2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language; bh=yyVY38m0aLPVO3kt/A/1zT0glESgtg5+gpd9k3xbVn8=; b=SAQ8kbrFlBQJcMiRBUomW1VFCs+FtCR0kBoafc5qrZqByoMdIKOWSrF4j6h8XcZtmF 1EM/wfLe7LdQpqv/w5z1irUBbeLiLJ0g6B0NRZfUPs7WGtlgZdpEC8s78Dc+yeqZ5fGA ueGbeMAeDPyswA9jW1GM2KeWN+ri68ev6mBHkTSuIEukdiAD1lyik9z4VH9TS5cfwUo2 beAqc3QVkQd2vd8VsCZQbmNpXh9tMsBZlUOodGugY+uhB9B4+RTyvKIktmVBZgL+kNwm 0FhvF5yY8Bl91vPLiw0IySFOmuAgzijSUoeoQHg9Dpu17zGdzv7W4LcRjK2xqqXDcYQL xWLQ== X-Gm-Message-State: APjAAAWNCdDOB8YKNVH9qTDwd8M0ZjKlcQIn7wEb+nJx6B9ku6Oaienh GqqPbPTHVRDyXtg7vLwepKRvFY5x/gY= X-Google-Smtp-Source: APXvYqwSY8mItgZ83oHk35WThUWHZN34q1aRPOvPRQo8WOjQ7Plfh9rVmdgzT7/XNi6jssFrJbAYiQ== X-Received: by 2002:a63:cf0b:: with SMTP id j11mr33725106pgg.240.1573552072315; Tue, 12 Nov 2019 01:47:52 -0800 (PST) Received: from [10.53.114.95] ([218.248.46.107]) by smtp.gmail.com with ESMTPSA id z11sm25663409pfg.117.2019.11.12.01.47.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Nov 2019 01:47:51 -0800 (PST) To: Gokul Bargaje , users@dpdk.org, dev@dpdk.org, "Mohit P. Tahiliani" References: From: Archit Pandey Organization: National Institute of Technology Surathkal Message-ID: <13e841db-63b8-9ca7-7e26-0da1ced4bdf2@gmail.com> Date: Tue, 12 Nov 2019 15:17:50 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-users] How to get the current timestamp in milliseconds in the DPDK? X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org Sender: "users" 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(); 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