Sha256: 40c0b84a40de870b155fe19e56f866f1ca790a56fb87b93cc84e3a4a53f7e581

Contents?: true

Size: 746 Bytes

Versions: 17

Compression:

Stored size: 746 Bytes

Contents

var profile = (function() {
  // Instrumentation for how much time we spend doing things. With 0 args,
  // returns current busy fraction. With a start and stop time in milliseconds, 
  // updates the current busy fraction.

  // Returns a load meter with a sampling period in ms.
  var load = function(period) {
    // Start of the sample interval
    var interval = 0;

    // Fraction of time busy
    var load = 0;
    var acc = 0;

    return function(t1, t2) {
      if (t1 === undefined) {
        return load;
      }

      if (interval < t2) {
        interval = (Math.floor(t2 / period) * period) + period;
        load = acc / period;
        acc = 0;
      }

      acc += (t2 - t1);
    }
  };

  return {
    load: load
  };
})();

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
riemann-dash-0.2.14 lib/riemann/dash/public/profile.js
riemann-dash-0.2.13 lib/riemann/dash/public/profile.js
riemann-dash-0.2.12 lib/riemann/dash/public/profile.js
riemann-dash-0.2.11 lib/riemann/dash/public/profile.js
riemann-dash-0.2.10 lib/riemann/dash/public/profile.js
riemann-dash-0.2.9 lib/riemann/dash/public/profile.js
riemann-dash-0.2.8 lib/riemann/dash/public/profile.js
riemann-dash-0.2.7 lib/riemann/dash/public/profile.js
riemann-dash-0.2.6 lib/riemann/dash/public/profile.js
riemann-dash-0.2.5 lib/riemann/dash/public/profile.js
riemann-dash-0.2.4 lib/riemann/dash/public/profile.js
riemann-dash-0.2.3 lib/riemann/dash/public/profile.js
mindreframer-riemann-dash-0.2.3 lib/riemann/dash/public/profile.js
mindreframer-reslike-dash-0.2.2 lib/riemann/dash/public/profile.js
riemann-dash-0.2.1 lib/riemann/dash/public/profile.js
riemann-dash-0.2.0 lib/riemann/dash/public/profile.js
riemann-dash-0.1.1 lib/riemann/dash/public/profile.js