I have a dll method that should be "QoSed" - this method should be called a maximum of 100 times per second .:
private static extern int ExecTrans(int connectionId);
This method is used only in one place in the program, so it is well suited for this place. I need a separate qos counter for each connectionId
. Therefore, ExecTrans(1)
and ExecTrans(2)
must go to different counters.
At first iteration, I would like to calculate how often the method is called (for each connectionId
). That is, I want to have "live statistics". There are two approaches:
- allow to exceed limitiation for a short period. for example allow "100 transaction from 0 to 1 second, 100 transaction from 1 to 2 seconds and 200 transactions from 0.5 to 1.5 second". - at any second interval transactions should not exceed 100.
At the moment, I donโt care which of these methods to use, but I would choose one, creating less โutilityโ ones. I want qos to add as little โextra work" as possible, because it traded software that was sensitive to every 0.1 ms.
Regarding the first approach, I think I can use something like this (pseudo code, maybe stats
and curStats
should be thread safe):
private int[] stats
As for the second approach ... is it possible to create a collection where the life of objects is exactly one second and will disappear after the second? Then every time I add the following object to the collection if the collection does not contain 100 objects.
What do you think? I am not familiar with C # library files, so maybe I am missing a useful class, maybe you can offer a different approach.
javapowered
source share