Re: GDI+ clock, GDI+ layered windows, text rendering, etc.
"valery_vi" <[email protected]>
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
The time intervals of new version of Clock can be measured by the
following func Draw:
Func Draw()
local $msg = '', $Start, $Time
; Calculate current time element position
$aLast = $aCurr
$aCurr[0][0] = $iCenter + Cos(TimeToRadians("sec" )) * $iSecRad
$aCurr[0][1] = $iCenter - Sin(TimeToRadians("sec" )) * $iSecRad
$aCurr[1][0] = $iCenter + Cos(TimeToRadians("min" )) * $iMinRad
$aCurr[1][1] = $iCenter - Sin(TimeToRadians("min" )) * $iMinRad
$aCurr[2][0] = $iCenter + Cos(TimeToRadians("hour")) * $iHourRad
$aCurr[2][1] = $iCenter - Sin(TimeToRadians("hour")) * $iHourRad
; Draw time elements
$Start = TimerInit()
TimeDraw()
$Time = TimerDiff($Start)
$msg &= 'TimeDraw = ' & $Time & @CrLf
$Start = TimerInit()
HourDraw()
$Time = TimerDiff($Start)
$msg &= 'HourDraw = ' & $Time & @CrLf
$Start = TimerInit()
MinDraw ()
$Time = TimerDiff($Start)
$msg &= 'MinDraw = ' & $Time & @CrLf
$Start = TimerInit()
SecDraw ()
$Time = TimerDiff($Start)
$msg &= 'SecDraw = ' & $Time & @CrLf
msgbox(0,'', $msg)
EndFunc
My result:
TimeDraw = 43.12
HourDraw = 61.84
MinDraw = 84.48
SecDraw = 105.91
CPU usage = 25% (average), but 1 time in 10 sec = 38%
As you can see Clock is making the same heavy work - it is spoiling
CPU.
Valery
--- In [email protected], "valery_vi" <shehrer1@...> wrote:
>
> PaulIA from AutoItScript forum wrote:
> http://www.autoitscript.com/forum/index.php?showtopic=48155
> '..
> >CPU before change was about 20%-25% (with other apps running)
> >after change CPU usage stayed about 6% but peaked about 20% every
so
> >often (same apps running)
>
> Thanks for your help in resolving this problem. I believe the new
> code I just put out should get you down to an acceptable CPU
> utilization.
> ..'
>
> You can show the time distribution in func Draw as follows:
>
> Func Draw()
> local $msg = '', $Start, $Time
> $Start = TimerInit()
> CalcHand()
> $Time = TimerDiff($Start)
> $msg &= 'CalcHand = ' & $Time & @CrLf
> $Start = TimerInit()
> DrawTime()
> $Time = TimerDiff($Start)
> $msg &= 'DrawTime = ' & $Time & @CrLf
> $Start = TimerInit()
> DrawHour()
> $Time = TimerDiff($Start)
> $msg &= 'DrawHour = ' & $Time & @CrLf
> $Start = TimerInit()
> DrawMin ()
> $Time = TimerDiff($Start)
> $msg &= 'DrawMin = ' & $Time & @CrLf
> $Start = TimerInit()
> DrawSec ()
> $Time = TimerDiff($Start)
> $msg &= 'DrawSec = ' & $Time & @CrLf
> msgbox(0,'', $msg)
> EndFunc
>
> Result for me:
> 0.38
> 47,0
> 63,5
> 83,8
> 103,9
>
> CPU usage - 20%
>
> Thus, functions Draw... are very raw and expansive!
>
> Valery
>