function addSumAndCountForExport(histogram) { return (acc, d) => { acc.push(...d.buckets); const infLabel = { le: '+Inf' }; for (const label of Object.keys(d.data.labels)) { infLabel[label] = d.data.labels[label]; } acc.push( setValuePair(infLabel, d.data.count, `${histogram.name}_bucket`), setValuePair(d.data.labels, d.data.sum, `${histogram.name}_sum`), setValuePair(d.data.labels, d.data.count, `${histogram.name}_count`), ); return acc; }; }
function getSumForExport(value, summary) { return { metricName: `${summary.name}_sum`, labels: value.labels, value: value.sum, }; }
function displayResults (results) { if (quiet === false) console.log('==========') const benchNames = Object.keys(results) for (var i = 0; i < benchNames.length; i += 1) { console.log(`${benchNames[i].toUpperCase()} benchmark averages`) const benchmark = results[benchNames[i]] const loggers = Object.keys(benchmark) for (var j = 0; j < loggers.length; j += 1) { var logger = benchmark[loggers[j]] var average = sum(logger) / logger.length console.log(`${loggers[j]} average: ${average.toFixed(3)}ms`) } } if (quiet === false) { console.log('==========') console.log( `System: ${type()}/${platform()} ${arch()} ${release()}`, `~ ${cpus()[0].model} (cores/threads: ${cpus().length})` ) } }
/** * _write expects data to be in the form of a datum. ie. {input: {a: 1 b: 0}, output: {z: 0}} * @param chunk * @param enc * @param next * @returns {*} * @private */ _write(chunk, enc, next) { if (!chunk) { // check for the end of one iteration of the stream this.emit('finish'); return next(); } if (!this.dataFormatDetermined) { this.size++; this.neuralNetwork.addFormat(chunk); this.firstDatum = this.firstDatum || chunk; return next(); } this.count++; const data = this.neuralNetwork.formatData(chunk); this.sum += this.neuralNetwork.trainPattern(data[0], true); // tell the Readable Stream that we are ready for more data next(); }
addItem(price) { this.num++; this.sum += price; }
summaryOfLabel.td.compress(); summaryOfLabel.sum += labelValuePair.value; this.hashMap[hash] = summaryOfLabel; };
v = jstat.sum( x ); if ( isnan( v ) ) { b.fail( 'should not return NaN' );
/** * Generate a snapshot for an item * * @param {Object} item * @param {String} key * @returns {Object} * @memberof HistogramMetric */ generateItemSnapshot(item, key) { const snapshot = { key, labels: item.labels, count: item.count, sum: item.sum, lastValue: item.lastValue, timestamp: item.timestamp, }; if (this.buckets) snapshot.buckets = this.buckets.reduce((a, b) => setProp(a, b, item.bucketValues[b]), {}); if (this.quantiles) Object.assign(snapshot, item.quantileValues.snapshot()); if (item.rate) snapshot.rate = item.rate.rate; return snapshot; }
addProduct(name, price) { this.sum += price; }
item.sum += value; item.count++; item.lastValue = value;
seeSum(sum) { assert.equal(sum, this.sum); }
valueFromMap.sum += labelValuePair.value; valueFromMap.count += 1;
v = jstat.sum( x ); if ( isnan( v ) ) { b.fail( 'should not return NaN' );