It is currently April 27th, 2024, 5:56 pm

Need help for code optimation

General topics related to Rainmeter.
slyphnier
Posts: 19
Joined: October 18th, 2011, 2:38 pm

Need help for code optimation

Post by slyphnier »

hello guys,

i am new to this forum
if someone have free time, i need little help to take this skin below, and how to optimize it
the skin running without problem, except it using quite high CPU usage (around 12% on i7 950)

its part of Qsystem skin (http://burnwell88.deviantart.com/gallery/#/d2yvsmn)

Code: Select all

[Rainmeter]
BackgroundMode=1
Author=yalishy (yalishy@gmail.com)
AppVersion=10000
Update=40

[Variables]
LineColor70=255,255,255,70
LineColor100=255,255,255,100
LineColor200=255,255,255,200
SolidColor=0,0,0,1
SolidColor200=255, 255, 255,200


[CalcMeasure2400]
Measure=Calc
Formula=Counter %2400

[CalcMeasure1500]
Measure=Calc
Formula=Counter %1500

[CalcMeasure1400]
Measure=Calc
Formula=Counter %1400

[CalcMeasure1000]
Measure=Calc
Formula=Counter %1000

[CalcMeasure900]
Measure=Calc
Formula=Counter %900

[MeasureTime2400]
Measure=Calc
Formula=CalcMeasure2400

[MeasureTime1500]
Measure=Calc
Formula=CalcMeasure1500

[MeasureTime1400]
Measure=Calc
Formula=CalcMeasure1400

[MeasureTime1000]
Measure=Calc
Formula=CalcMeasure1000

[MeasureTime900]
Measure=Calc
Formula=CalcMeasure900

-------------------------------------------------------------------------------------------

[MeterUnder7]
MeasureName=MeasureTime1500
Meter=ROTATOR
X=347
Y=145
W=387
H=387
ImageName=1x.png
StartAngle=6.2832
RotationAngle=6.2832
ValueReminder=1500
OffsetX=190
OffsetY=190
Hidden=0

[MeterUnder8]
MeasureName=MeasureTime1000
Meter=ROTATOR
X=347
Y=145
W=387
H=387
ImageName=2x.png
StartAngle=6.2832
RotationAngle=-6.2832
ValueReminder=1000
OffsetX=190
OffsetY=190
Hidden=0

[MeterUnder9]
MeasureName=MeasureTime900
Meter=ROTATOR
X=347
Y=145
W=387
H=387
ImageName=3x.png
StartAngle=6.2832
RotationAngle=6.2832
ValueReminder=900
OffsetX=190
OffsetY=190
Hidden=0

[MeterUnder10]
MeasureName=MeasureTime1400
Meter=ROTATOR
X=350
Y=148
W=381
H=381
ImageName=5x.png
StartAngle=6.2832
RotationAngle=6.2832
ValueReminder=1400
OffsetX=190
OffsetY=190
Hidden=0

[MeterUnder11]
MeasureName=MeasureTime2400
Meter=ROTATOR
X=315
Y=114
W=450
H=450
ImageName=6x.png
StartAngle=6.2832
RotationAngle=6.2832
ValueReminder=2400
OffsetX=219
OffsetY=219
Hidden=0

==================================================================================

[MeasureRing2]
Measure=Calc
Formula=360

[MeterAnalogBG1]
Meter=ROUNDLINE
MeasureName=MeasureRing2
X=336
Y=133
W=410
H=410
LineWidth=5.0
LineLength=201
LineStart=200
StartAngle=47.55
RotationAngle=6.2832
AntiAlias=1
LineColor=#LineColor100#
Solid=1

[MeterAnalogBG2]
Meter=ROUNDLINE
MeasureName=MeasureRing2
X=336
Y=133
W=410
H=410
LineWidth=5.0
LineLength=206
LineStart=205
StartAngle=2.3561945
RotationAngle=1.5707963
AntiAlias=1
LineColor=#LineColor200#
Solid=1

[MeterAnalogBG3]
Meter=ROUNDLINE
MeasureName=MeasureRing2
X=336
Y=133
W=410
H=410
LineWidth=5.0
LineLength=206
LineStart=205
StartAngle=5.4977871
RotationAngle=1.5707963
AntiAlias=1
LineColor=#LineColor200#
Solid=1

[MeterAnalogBG333]
Meter=ROUNDLINE
MeasureName=MeasureRing2
X=336
Y=133
W=410
H=410
LineWidth=5.0
LineLength=145
LineStart=144
StartAngle=47.55
RotationAngle=6.2832
AntiAlias=1
LineColor=255,255,255,70
Solid=1

[MeterBackground1]
Meter=IMAGE
X=750
Y=339
W=256
H=1
SolidColor=#SolidColor200#
SolidColor2=#SolidColor#
GradientAngle=0

[MeterBackground2]
Meter=IMAGE
X=77
Y=339
W=256
H=1
SolidColor=#SolidColor#
SolidColor2=#SolidColor200#
GradientAngle=0

===================================================================================
i tried email the developer too, but i thought it might be faster to get help in here
hope someone can help

thanks in advance :welcome:
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Need help for code optimation

Post by smurfier »

It's the Update=40 part. You can increase that number to make things more CUP efficient, but the rotators will move slower.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
slyphnier
Posts: 19
Joined: October 18th, 2011, 2:38 pm

Re: Need help for code optimation

Post by slyphnier »

thanks for the info smurfier

so seems not much we can about it...
do rainmeter have delay function ?
maybe it wont different, but i am thinking stacking/queing few order/command every refresh

instead 40ms refresh, 1000ms refresh but each refresh run A > delay > run B > delay > run C and so on ...
i didn't know much programing so it might still cpu intensive (nothing different)
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: Need help for code optimation

Post by MerlinTheRed »

That skin basically only does an animation. If you delayed commands within it and then did them all at the same time, the animation would look weird. If you just increase the update rate the animation will look slower but likely still fluid.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Need help for code optimation

Post by smurfier »

I've reduced the code a bit. With the lack of the image files, and my limited knowledge of the Rotator meter, I cannot be sure that this code will work perfectly.

Code: Select all

[Rainmeter]
Author=yalishy (yalishy@gmail.com)
Update=40

[Variables]
LineColor70=255,255,255,70
LineColor100=255,255,255,100
LineColor200=255,255,255,200
SolidColor=0,0,0,1
SolidColor200=255, 255, 255,200

[CalcMeasure]
Measure=Calc
Formula=CalcMeasure+1

;-------------------------------------------------------------------------------------------

[MeterUnder7]
MeasureName=CalcMeasure
Meter=ROTATOR
X=347
Y=145
W=387
H=387
ImageName=1x.png
StartAngle=6.2832
RotationAngle=6.2832
ValueRemainder=1500
OffsetX=190
OffsetY=190

[MeterUnder8]
MeasureName=CalcMeasure
Meter=ROTATOR
X=347
Y=145
W=387
H=387
ImageName=2x.png
StartAngle=6.2832
RotationAngle=-6.2832
ValueRemainder=1000
OffsetX=190
OffsetY=190

[MeterUnder9]
MeasureName=CalcMeasure
Meter=ROTATOR
X=347
Y=145
W=387
H=387
ImageName=3x.png
StartAngle=6.2832
RotationAngle=6.2832
ValueRemainder=900
OffsetX=190
OffsetY=190

[MeterUnder10]
MeasureName=CalcMeasure
Meter=ROTATOR
X=350
Y=148
W=381
H=381
ImageName=5x.png
StartAngle=6.2832
RotationAngle=6.2832
ValueRemainder=1400
OffsetX=190
OffsetY=190

[MeterUnder11]
MeasureName=CalcMeasure
Meter=ROTATOR
X=315
Y=114
W=450
H=450
ImageName=6x.png
StartAngle=6.2832
RotationAngle=6.2832
ValueRemainder=2400
OffsetX=219
OffsetY=219

;==================================================================================

[MeasureRing2]
Measure=Calc
Formula=1

[RoundStyle]
MeasureName=MeasureRing2
LineWidth=5
Solid=1
AntiAlias=1
X=336
Y=133
W=410
H=410

[MeterAnalogBG1]
Meter=ROUNDLINE
MeterStyle=RoundStyle
LineLength=201
LineStart=200
StartAngle=47.55
LineColor=#LineColor100#

[MeterAnalogBG2]
Meter=ROUNDLINE
MeterStyle=RoundStyle
LineLength=206
LineStart=205
StartAngle=2.3561945
RotationAngle=1.5707963
LineColor=#LineColor200#

[MeterAnalogBG3]
Meter=ROUNDLINE
MeterStyle=RoundStyle
LineLength=206
LineStart=205
StartAngle=5.4977871
RotationAngle=1.5707963
LineColor=#LineColor200#

[MeterAnalogBG333]
Meter=ROUNDLINE
MeterStyle=RoundStyle
LineLength=145
LineStart=144
StartAngle=47.55
LineColor=255,255,255,70

[MeterBackground1]
Meter=IMAGE
X=750
Y=339
W=256
H=1
SolidColor=#SolidColor200#
SolidColor2=#SolidColor#

[MeterBackground2]
Meter=IMAGE
MeterStyle=MeterBackground1
X=77
Y=339
W=256

;===================================================================================
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
slyphnier
Posts: 19
Joined: October 18th, 2011, 2:38 pm

Re: Need help for code optimation

Post by slyphnier »

thanks for the time modding the code smurfier :bow2:
the code working just right (no errors) :thumbup:

but too bad it still taking cpu, seems still same (on i7 950 it using 12.5%) :(
your code is better than the original one though

that rotator look really cool on the desktop, but using 12.5% isnt really good things :???: