docs: function(start, end) {
        var measurementRange = tr.b.Range.fromExplicitRange(start, end);
  
        var energyConsumed = 0;
        for (var i = 0; i < this.samples.length; i++) {
          var sample = this.samples[i];
          var nextSample = this.samples[i + 1];
  
          var sampleRange = new tr.b.Range();
          sampleRange.addValue(sample.start);
          sampleRange.addValue(nextSample ? nextSample.start : Infinity);
  
          var timeIntersection = measurementRange.findIntersection(sampleRange);
  
          // Divide by 1000 to convert milliseconds to seconds.
          energyConsumed += timeIntersection.duration / 1000 * sample.power;
        }
  
        return energyConsumed;
      }