I have got a function which is called periodically by other c++ class. Below is a prototype
void onNewButtonPress(int64_t nanoseconds_timestamp, int32_t user_id);
This function will be called each time a user with a user_id is pressing the button. Where nanoseconds_timestamp parameter is the time in nanoseconds since the epoch
This function will need to get the rate of user button presses, basically how many times per second a user pressed a button.
How can I calculate the rate for each user, store it and update it periodically? Is it possible to do it using just above function or I will have to create another function which will be called periodically and will calculate the rates.
How do I deal with users which started pressing button close to the end of the period. Do I need to average it?
I will be very interested to hear your opinions based on your experience.
Aucun commentaire:
Enregistrer un commentaire