Home » U++ Library support » U++ Callbacks and Timers » TimerCallBack interval resolution
TimerCallBack interval resolution [message #58017] |
Wed, 19 January 2022 07:41 |
|
deep
Messages: 263 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
Hi
I am experimenting with TimerCallBack. I want to set callback interval to say 25 ms.
To check this I have done small code sample. It is attached to this message.
I am measuring delay with GetTickCount(). Running this for 10 sec. And counting - Histogram.
My observation shows time aligns to 20 ms
Timer Delay -20
Time Count
20 320
21 160
22 5
23 2
28 1
37 1
Timer Delay -25
Time Count
28 1
30 1
34 1
40 102
41 142
Timer Delay -19
Time Count
19 2
20 331
21 147
22 5
23 1
24 1
31 1
60 1
Timer Delay -22
Time Count
22 3
23 2
24 5
40 116
41 113
43 1
Timer Delay -38
Time Count
40 114
41 131
55 1
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct TimerCallBackVariation : TopWindow
{
Vector<int> interval;
dword prev, now;
TimeCallback timer, process;
int timerDelay, processDelay;
LineEdit le1;
String Result;
void Timer()
{
now = GetTickCount();
interval.Add ( now - prev );
prev = now ;
}
void Process()
{
timer.Kill();
Result << "Count - " << interval.GetCount() << "\n";
Result << "Interval Vector - " << interval << "\n" ;
Sort ( interval );
Result << "Sorted - " << interval << "\n";
VectorMap<int, int> hist;
int j, k;
for ( int i = 0; i < interval.GetCount(); i++ )
{
j = interval[i];
k = hist.Find ( j );
if ( k > -1 )
{
hist[k] = hist[k] + 1;
}
else
{
hist.Add ( j, 1 );
}
}
Result << "\nTimer Delay " << timerDelay << "\n";
Result << "Time \tCount" "\n";
for ( int i = 0; i < hist.GetCount(); i++ )
{
Result << hist.GetKey ( i ) << " \t" << hist.GetValues() [i] << "\n";
}
this->Title ( "Done" );
le1.Paste(Result.ToWString());
}
TimerCallBackVariation()
{
timerDelay = -38;
processDelay = 10000;
Title ( "Timer Callback Time Variation" ).Zoomable().Sizeable();
Add(le1);
le1.SizePos();
prev = GetTickCount();
timer.Set ( timerDelay, [=] {Timer();} );
process.Set ( processDelay, [=] { Process();} );
}
};
GUI_APP_MAIN
{
TimerCallBackVariation app;
app.Run();
}
Warm Regards
Deepak
|
|
|
|
|
TimerCallBack interval resolution
By: deep on Wed, 19 January 2022 07:41
|
|
|
Re: TimerCallBack interval resolution
By: Tom1 on Wed, 19 January 2022 13:19
|
|
|
Re: TimerCallBack interval resolution
By: deep on Wed, 19 January 2022 14:27
|
|
|
Re: TimerCallBack interval resolution
By: Tom1 on Wed, 19 January 2022 14:40
|
|
|
Re: TimerCallBack interval resolution
By: Didier on Thu, 20 January 2022 21:43
|
|
|
Re: TimerCallBack interval resolution
By: deep on Fri, 21 January 2022 07:39
|
|
|
Re: TimerCallBack interval resolution
By: mirek on Sat, 22 January 2022 19:32
|
|
|
Re: TimerCallBack interval resolution
By: deep on Mon, 24 January 2022 09:56
|
|
|
Re: TimerCallBack interval resolution
By: mirek on Mon, 24 January 2022 10:47
|
|
|
Re: TimerCallBack interval resolution
By: superdev on Wed, 04 January 2023 20:19
|
|
|
Re: TimerCallBack interval resolution
By: mirek on Thu, 05 January 2023 09:29
|
|
|
Re: TimerCallBack interval resolution
By: superdev on Fri, 06 January 2023 16:20
|
|
|
Re: TimerCallBack interval resolution
By: mirek on Sat, 07 January 2023 09:10
|
|
|
Re: TimerCallBack interval resolution
By: superdev on Sat, 07 January 2023 11:05
|
|
|
Re: TimerCallBack interval resolution
By: mirek on Sat, 07 January 2023 13:15
|
|
|
Re: TimerCallBack interval resolution
By: superdev on Sun, 08 January 2023 06:38
|
|
|
Re: TimerCallBack interval resolution
By: superdev on Tue, 10 January 2023 19:12
|
|
|
Re: TimerCallBack interval resolution
By: mirek on Wed, 11 January 2023 10:36
|
|
|
Re: TimerCallBack interval resolution
By: superdev on Wed, 11 January 2023 18:17
|
Goto Forum:
Current Time: Tue Apr 23 15:03:54 CEST 2024
Total time taken to generate the page: 0.02218 seconds
|