It is currently March 29th, 2024, 8:51 am

Instantaneous CPS algorithm

Get help with creating, editing & fixing problems with skins
User avatar
EnhancedJax
Posts: 19
Joined: October 17th, 2020, 11:57 am

Instantaneous CPS algorithm

Post by EnhancedJax »

Hey, back with another question :welcome:, I am trying to figure out how to calculate the instant clicks per second, which is the CPS for the last second, and not the usual Clicks/Second average CPS. Here is the dummy code:

Code: Select all

[Rainmeter]
Update=100

[Variables]
Clicks=0

[SecondsElapsed]
Measure=Calc
Formula=SecondsElapsed + 0.1

[Calc]
Measure=Calc
Formula=#Clicks# / SecondsElapsed
DynamicVariables=1

[Button]
Meter=String
Text=[calc]
W=100
H=100
DynamicVariables=1
SolidColor=255,0,0
LeftMouseUpAction=[!SetVariable Clicks (#Clicks#+1)][!UpdateMeter *][!UpdateMeasure calc][!Redraw]
This code would only get the average CPS, which isn't what it wanted. Any ideas?
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Instantaneous CPS algorithm

Post by Yincognito »

EnhancedJax wrote: August 8th, 2021, 10:15 am Hey, back with another question :welcome:, I am trying to figure out how to calculate the instant clicks per second, which is the CPS for the last second, and not the usual Clicks/Second average CPS. Here is the dummy code:

Code: Select all

[Rainmeter]
Update=100

[Variables]
Clicks=0

[SecondsElapsed]
Measure=Calc
Formula=SecondsElapsed + 0.1

[Calc]
Measure=Calc
Formula=#Clicks# / SecondsElapsed
DynamicVariables=1

[Button]
Meter=String
Text=[calc]
W=100
H=100
DynamicVariables=1
SolidColor=255,0,0
LeftMouseUpAction=[!SetVariable Clicks (#Clicks#+1)][!UpdateMeter *][!UpdateMeasure calc][!Redraw]
This code would only get the average CPS, which isn't what it wanted. Any ideas?
First, Rainmeter isn't that precise if you want to accurately measure time using the update rate - better use Time measures instead.

Secondly, all you'd need is a Time measure that resets the click counter to 0 in its OnChangeAction, in order to get the CPS for the last second. Obviously, you won't need to divide by anything since it's just about a single second.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
EnhancedJax
Posts: 19
Joined: October 17th, 2020, 11:57 am

Re: Instantaneous CPS algorithm

Post by EnhancedJax »

Yincognito wrote: August 8th, 2021, 10:40 am First, Rainmeter isn't that precise if you want to accurately measure time using the update rate - better use Time measures instead.
Hmm... I am not sure how I can achieve that with a time measure...
Yincognito wrote: August 8th, 2021, 10:40 am Secondly, all you'd need is a Time measure that resets the click counter to 0 in its OnChangeAction, in order to get the CPS for the last second.
I've also thought about this, but the problem is that the value would drop to 0 on each new second. The instant CPS should be amount of clicks for the last second, but not snapped to the start of the second (so basically the y value of a cps-time graph). The key difference here is that average CPS is considering all collected data, but instant only considers the last second's data.

p.s. sorry if this is confusing, I am really bad at explaining things :oops:
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Instantaneous CPS algorithm

Post by Yincognito »

EnhancedJax wrote: August 8th, 2021, 10:51 am Hmm... I am not sure how I can achieve that with a time measure...



I've also thought about this, but the problem is that the value would drop to 0 on each new second. The instant CPS should be amount of clicks for the last second, but not snapped to the start of the second (so basically the y value of a cps-time graph). The key difference here is that average CPS is considering all collected data, but instant only considers the last second's data.

p.s. sorry if this is confusing, I am really bad at explaining things :oops:
I can't write the code for it ATM, as I'm on mobile, but I'm not sure if I follow. Resetting the counter to 0 doesn't mean you can't count clicks anymore (that part stays unchanged in your code), it only means things are calculated for ... well, the last second, which is exactly what you said you wanted. :confused:

Or, maybe you meant showing the number of clicks for the PREVIOUS second?
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Instantaneous CPS algorithm

Post by death.crafter »

EnhancedJax wrote: August 8th, 2021, 10:51 am Hmm... I am not sure how I can achieve that with a time measure...



I've also thought about this, but the problem is that the value would drop to 0 on each new second. The instant CPS should be amount of clicks for the last second, but not snapped to the start of the second (so basically the y value of a cps-time graph). The key difference here is that average CPS is considering all collected data, but instant only considers the last second's data.

p.s. sorry if this is confusing, I am really bad at explaining things :oops:

Code: Select all

[Starter]
...
LeftMouseUpAction=[!HideMeter #CURRENTSECTION#][!ShowMeterClicker][!Redraw][!Delay 1000][!HideMeter Clicker][!Redraw][!UpdateMeter Result][!ShowMeter Result][!Redraw]

[Clicker]
...
LeftMouseUpAction=[!SetVariable Clicked "(#Clicked#+1)"]

[Result]
...
from the Realm of Death
User avatar
EnhancedJax
Posts: 19
Joined: October 17th, 2020, 11:57 am

Re: Instantaneous CPS algorithm

Post by EnhancedJax »

Yincognito wrote: August 8th, 2021, 10:59 am I can't write the code for it ATM, as I'm on mobile, but I'm not sure if I follow. Resetting the counter to 0 doesn't mean you can't count clicks anymore (that part stays unchanged in your code), it only means things are calculated for ... well, the last second, which is exactly what you said you wanted. :confused:

Or, maybe you meant showing the number of clicks for the PREVIOUS second?
Resetting the counter to 0 would result in a instant CPS of 0, which isn't what it should be if clicks are continuous. For "the last second", it doesn't mean to reset + calculate CPS for the next second, but rather remove clicks 1000ms before, and only use the ones present to calculate the CPS (which should be exactly the same as the present amount of clicks).
death.crafter wrote: August 8th, 2021, 11:04 am

Code: Select all

[Starter]
...
LeftMouseUpAction=[!HideMeter #CURRENTSECTION#][!ShowMeterClicker][!Redraw][!Delay 1000][!HideMeter Clicker][!Redraw][!UpdateMeter Result][!ShowMeter Result][!Redraw]

[Clicker]
...
LeftMouseUpAction=[!SetVariable Clicked "(#Clicked#+1)"]

[Result]
...
This would create a CPS counter to calculate the CPS for the next second, and show the result after 1000ms, right? I don't think this is what I am looking for... :confused:
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Instantaneous CPS algorithm

Post by death.crafter »

EnhancedJax wrote: August 8th, 2021, 11:12 am Resetting the counter to 0 would result in a instant CPS of 0, which isn't what it should be if clicks are continuous. For "the last second", it doesn't mean to reset + calculate CPS for the next second, but rather remove clicks 1000ms before, and only use the ones present to calculate the CPS (which should be exactly the same as the present amount of clicks).



This would create a CPS counter to calculate the CPS for the next second, and show the result after 1000ms, right? I don't think this is what I am looking for... :confused:
What do you mean by in the past second? If you have results it it is already in the past :confused:

Can you explain like how does that work in a non rainmeter way?
from the Realm of Death
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Instantaneous CPS algorithm

Post by death.crafter »

Do you mean like the time difference between two consecutive clicks and calculate the cps from that? I can only get this idea by instantaneous.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Instantaneous CPS algorithm

Post by Yincognito »

I think he means the number of clicks for the duration of a past second, but FROM THE CURRENT CLICK backwards...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
EnhancedJax
Posts: 19
Joined: October 17th, 2020, 11:57 am

Re: Instantaneous CPS algorithm

Post by EnhancedJax »

Yincognito wrote: August 8th, 2021, 11:21 am I think he means the number of clicks for the duration of a past second, but FROM THE CURRENT CLICK backwards...
Yeah. that's it.

For example, if we have a data set like this:
Sec1: 5 clicks (0 to 1)s
Sec2: 7 clicks (1 to 2)s
If the time extracting the CPS is at 1.5s, it would be the num of clicks from 0.5s to 1.5s, lets expand the data set
Column: Each 100ms, row: each sec
Sec1: 0 1 0 0 1 1 1 1 1 0
Sec2: 1 1 1 0 0 1 1 0 0 0
the CPS then would be [ 1 1 1 1 0 1 1 1 0 0 ] -> 7

If we set the "instant range" as 1, we would always get an integer, for a smoother result we could use 2 as the "instant range"... so I guess what is left is the execution?