public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* "[edk] Caculating time delay in milliseconds"
@ 2017-03-02 11:53 Arka Sharma
  2017-03-02 12:05 ` Michael Zimmermann
  0 siblings, 1 reply; 6+ messages in thread
From: Arka Sharma @ 2017-03-02 11:53 UTC (permalink / raw)
  To: edk2-devel

gRT->GetTime() is accurate about seconds.Is there any way to calculate
time difference in milliseconds ?
Let's say

Time1 = GetTimeMs();

//
// Some tasks
//

Time2 = GetTimeMs();

//
// Time taken
//
GetTimeDiff (Time1, Time2);

Something like this

Regards,
Arka


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

* Re: "[edk] Caculating time delay in milliseconds"
  2017-03-02 11:53 "[edk] Caculating time delay in milliseconds" Arka Sharma
@ 2017-03-02 12:05 ` Michael Zimmermann
  2017-03-02 18:08   ` Kinney, Michael D
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Zimmermann @ 2017-03-02 12:05 UTC (permalink / raw)
  To: Arka Sharma; +Cc: edk2-devel@lists.01.org

AFAIK the only way to do that is to use the platform specific TimerLib
like this:

UINT64
GetTimeMs (
  VOID
)
{
  return GetTimeInNanoSecond(GetPerformanceCounter()) / 1000000ULL;
}

Thanks
Michael

On Thu, Mar 2, 2017 at 12:53 PM, Arka Sharma <arka.sw1988@gmail.com> wrote:
> gRT->GetTime() is accurate about seconds.Is there any way to calculate
> time difference in milliseconds ?
> Let's say
>
> Time1 = GetTimeMs();
>
> //
> // Some tasks
> //
>
> Time2 = GetTimeMs();
>
> //
> // Time taken
> //
> GetTimeDiff (Time1, Time2);
>
> Something like this
>
> Regards,
> Arka
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: "[edk] Caculating time delay in milliseconds"
  2017-03-02 12:05 ` Michael Zimmermann
@ 2017-03-02 18:08   ` Kinney, Michael D
  2017-03-06  4:20     ` Arka Sharma
  2017-03-06  4:30     ` Arka Sharma
  0 siblings, 2 replies; 6+ messages in thread
From: Kinney, Michael D @ 2017-03-02 18:08 UTC (permalink / raw)
  To: Michael Zimmermann, Arka Sharma; +Cc: edk2-devel@lists.01.org

For UEFI Drivers/Applications there is also the EFI_TIMESTAMP_PROTOCOL
if it is available on your platform.

Mike

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Michael
> Zimmermann
> Sent: Thursday, March 2, 2017 4:06 AM
> To: Arka Sharma <arka.sw1988@gmail.com>
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] "[edk] Caculating time delay in milliseconds"
> 
> AFAIK the only way to do that is to use the platform specific TimerLib
> like this:
> 
> UINT64
> GetTimeMs (
>   VOID
> )
> {
>   return GetTimeInNanoSecond(GetPerformanceCounter()) / 1000000ULL;
> }
> 
> Thanks
> Michael
> 
> On Thu, Mar 2, 2017 at 12:53 PM, Arka Sharma <arka.sw1988@gmail.com> wrote:
> > gRT->GetTime() is accurate about seconds.Is there any way to calculate
> > time difference in milliseconds ?
> > Let's say
> >
> > Time1 = GetTimeMs();
> >
> > //
> > // Some tasks
> > //
> >
> > Time2 = GetTimeMs();
> >
> > //
> > // Time taken
> > //
> > GetTimeDiff (Time1, Time2);
> >
> > Something like this
> >
> > Regards,
> > Arka
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: "[edk] Caculating time delay in milliseconds"
  2017-03-02 18:08   ` Kinney, Michael D
@ 2017-03-06  4:20     ` Arka Sharma
  2017-03-06  4:30     ` Arka Sharma
  1 sibling, 0 replies; 6+ messages in thread
From: Arka Sharma @ 2017-03-06  4:20 UTC (permalink / raw)
  To: Kinney, Michael D; +Cc: Michael Zimmermann, edk2-devel@lists.01.org

Thanks Michael for your reply.The function GetPerformanceCounter() is
returning 0 is my platform.

On Thu, Mar 2, 2017 at 11:38 PM, Kinney, Michael D
<michael.d.kinney@intel.com> wrote:
> For UEFI Drivers/Applications there is also the EFI_TIMESTAMP_PROTOCOL
> if it is available on your platform.
>
> Mike
>
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Michael
>> Zimmermann
>> Sent: Thursday, March 2, 2017 4:06 AM
>> To: Arka Sharma <arka.sw1988@gmail.com>
>> Cc: edk2-devel@lists.01.org
>> Subject: Re: [edk2] "[edk] Caculating time delay in milliseconds"
>>
>> AFAIK the only way to do that is to use the platform specific TimerLib
>> like this:
>>
>> UINT64
>> GetTimeMs (
>>   VOID
>> )
>> {
>>   return GetTimeInNanoSecond(GetPerformanceCounter()) / 1000000ULL;
>> }
>>
>> Thanks
>> Michael
>>
>> On Thu, Mar 2, 2017 at 12:53 PM, Arka Sharma <arka.sw1988@gmail.com> wrote:
>> > gRT->GetTime() is accurate about seconds.Is there any way to calculate
>> > time difference in milliseconds ?
>> > Let's say
>> >
>> > Time1 = GetTimeMs();
>> >
>> > //
>> > // Some tasks
>> > //
>> >
>> > Time2 = GetTimeMs();
>> >
>> > //
>> > // Time taken
>> > //
>> > GetTimeDiff (Time1, Time2);
>> >
>> > Something like this
>> >
>> > Regards,
>> > Arka
>> > _______________________________________________
>> > edk2-devel mailing list
>> > edk2-devel@lists.01.org
>> > https://lists.01.org/mailman/listinfo/edk2-devel
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: "[edk] Caculating time delay in milliseconds"
  2017-03-02 18:08   ` Kinney, Michael D
  2017-03-06  4:20     ` Arka Sharma
@ 2017-03-06  4:30     ` Arka Sharma
  2017-03-06  6:52       ` Michael Zimmermann
  1 sibling, 1 reply; 6+ messages in thread
From: Arka Sharma @ 2017-03-06  4:30 UTC (permalink / raw)
  To: Kinney, Michael D; +Cc: Michael Zimmermann, edk2-devel@lists.01.org

Thanks Mike for the reply but EFI_TIMESTAMP_PROTOCOL is not there in
my platform. I tried to open it using gBS->LocateProtocol() and it
returned EFI_NOT_FOUND

On Thu, Mar 2, 2017 at 11:38 PM, Kinney, Michael D
<michael.d.kinney@intel.com> wrote:
> For UEFI Drivers/Applications there is also the EFI_TIMESTAMP_PROTOCOL
> if it is available on your platform.
>
> Mike
>
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Michael
>> Zimmermann
>> Sent: Thursday, March 2, 2017 4:06 AM
>> To: Arka Sharma <arka.sw1988@gmail.com>
>> Cc: edk2-devel@lists.01.org
>> Subject: Re: [edk2] "[edk] Caculating time delay in milliseconds"
>>
>> AFAIK the only way to do that is to use the platform specific TimerLib
>> like this:
>>
>> UINT64
>> GetTimeMs (
>>   VOID
>> )
>> {
>>   return GetTimeInNanoSecond(GetPerformanceCounter()) / 1000000ULL;
>> }
>>
>> Thanks
>> Michael
>>
>> On Thu, Mar 2, 2017 at 12:53 PM, Arka Sharma <arka.sw1988@gmail.com> wrote:
>> > gRT->GetTime() is accurate about seconds.Is there any way to calculate
>> > time difference in milliseconds ?
>> > Let's say
>> >
>> > Time1 = GetTimeMs();
>> >
>> > //
>> > // Some tasks
>> > //
>> >
>> > Time2 = GetTimeMs();
>> >
>> > //
>> > // Time taken
>> > //
>> > GetTimeDiff (Time1, Time2);
>> >
>> > Something like this
>> >
>> > Regards,
>> > Arka
>> > _______________________________________________
>> > edk2-devel mailing list
>> > edk2-devel@lists.01.org
>> > https://lists.01.org/mailman/listinfo/edk2-devel
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: "[edk] Caculating time delay in milliseconds"
  2017-03-06  4:30     ` Arka Sharma
@ 2017-03-06  6:52       ` Michael Zimmermann
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Zimmermann @ 2017-03-06  6:52 UTC (permalink / raw)
  To: Arka Sharma; +Cc: Kinney, Michael D, edk2-devel@lists.01.org

Another way that can be very unreliable though is creating a timer
event using CreateEvent and incrementing a counter inside the
callback.
This will not give you exact values and the results can vary greatly
depending on the platform implementation and the cpu load but in
theory it should be better than GetTime - at least for calculating
time differences(not for absolute time).

Thanks
Michael

On Mon, Mar 6, 2017 at 5:30 AM, Arka Sharma <arka.sw1988@gmail.com> wrote:
> Thanks Mike for the reply but EFI_TIMESTAMP_PROTOCOL is not there in
> my platform. I tried to open it using gBS->LocateProtocol() and it
> returned EFI_NOT_FOUND
>
> On Thu, Mar 2, 2017 at 11:38 PM, Kinney, Michael D
> <michael.d.kinney@intel.com> wrote:
>> For UEFI Drivers/Applications there is also the EFI_TIMESTAMP_PROTOCOL
>> if it is available on your platform.
>>
>> Mike
>>
>>> -----Original Message-----
>>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Michael
>>> Zimmermann
>>> Sent: Thursday, March 2, 2017 4:06 AM
>>> To: Arka Sharma <arka.sw1988@gmail.com>
>>> Cc: edk2-devel@lists.01.org
>>> Subject: Re: [edk2] "[edk] Caculating time delay in milliseconds"
>>>
>>> AFAIK the only way to do that is to use the platform specific TimerLib
>>> like this:
>>>
>>> UINT64
>>> GetTimeMs (
>>>   VOID
>>> )
>>> {
>>>   return GetTimeInNanoSecond(GetPerformanceCounter()) / 1000000ULL;
>>> }
>>>
>>> Thanks
>>> Michael
>>>
>>> On Thu, Mar 2, 2017 at 12:53 PM, Arka Sharma <arka.sw1988@gmail.com> wrote:
>>> > gRT->GetTime() is accurate about seconds.Is there any way to calculate
>>> > time difference in milliseconds ?
>>> > Let's say
>>> >
>>> > Time1 = GetTimeMs();
>>> >
>>> > //
>>> > // Some tasks
>>> > //
>>> >
>>> > Time2 = GetTimeMs();
>>> >
>>> > //
>>> > // Time taken
>>> > //
>>> > GetTimeDiff (Time1, Time2);
>>> >
>>> > Something like this
>>> >
>>> > Regards,
>>> > Arka
>>> > _______________________________________________
>>> > edk2-devel mailing list
>>> > edk2-devel@lists.01.org
>>> > https://lists.01.org/mailman/listinfo/edk2-devel
>>> _______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.01.org
>>> https://lists.01.org/mailman/listinfo/edk2-devel


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

end of thread, other threads:[~2017-03-06  6:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-02 11:53 "[edk] Caculating time delay in milliseconds" Arka Sharma
2017-03-02 12:05 ` Michael Zimmermann
2017-03-02 18:08   ` Kinney, Michael D
2017-03-06  4:20     ` Arka Sharma
2017-03-06  4:30     ` Arka Sharma
2017-03-06  6:52       ` Michael Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox