Note that there are some explanatory texts on larger screens.

plurals
  1. POboost accumulator rolling count non zero
    primarykey
    data
    text
    <p>I am trying to use accumulators to find out statistics for a given activity per sec. Below are the two stats I would like to compute</p> <ul> <li>Number of times activity has been triggered</li> <li><p>Sum of the total weight triggered by the activity.</p> <p>To achieve I have assumed a granularity by 10 msecs and considering 100 buckets ( per sec ).</p></li> <li>Actvity Thread inserts into accumulator whenever there is an event</li> <li>Null Activity Thread wakes up every 10 msecs to insert 0 in the weight.</li> </ul> <p>Psuedo code below</p> <pre><code>#include &lt;boost/accumulators/accumulators.hpp&gt; #include &lt;boost/accumulators/statistics/stats.hpp&gt; #include &lt;boost/accumulators/statistics/rolling_count.hpp&gt; #include &lt;boost/accumulators/statistics/rolling_sum.hpp&gt; using namespace boost::accumulators; #define MAX_WEIGHT 100 #define MAX_ACIVITY 10 accumulator_set&lt;double, features&lt;tag::rolling_count, tag::rolling_sum&gt; &gt; acc(tag::rolling_window::window_size = 100); void null_run()//invoked every 10 msecs { //mutex protected acc(0); } void activity_triggered(int weight) // triggered by an external event { //mutex protected acc(weight); if (checkStatus() == false) { printf("Max quantity per sec reached stop "); exit() } } bool checkStatus() { int weightPerSec = rolling_sum(acc); //here I would like to get the count only if non zero may be rolling_count_non_zero()?? int acitivitiesPersec = rolling_count(acc); if (weightPerSec &gt; MAX_WEIGHT) return false; if (acitivitiesPersec &gt; MAX_ACTIVITY) return false; return true; } </code></pre> <p>Using above technique i am able to achieve weight entered in the last second but how do I achieve how many times has the activity been triggered in the last sec using boost accumulators ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload