log generator improvements

This commit is contained in:
Spencer Alger
2014-04-23 19:06:47 -07:00
parent f00cb0b9ba
commit 4a54417f29
5 changed files with 615 additions and 72 deletions

View File

@ -8,11 +8,12 @@ var dayMs = 86400000;
exports.make = function (startingMoment, endingMoment) {
var sets = {};
var startms = startingMoment.toDate().getTime();
var endms = endingMoment.toDate().getTime();
sets.randomMsInDayRange = new Stochator({
min: startingMoment.toDate().getTime(),
max: endingMoment.toDate().getTime()
}, 'get');
sets.randomMsInDayRange = function () {
return _.random(startms, endms);
};
sets.lessRandomRespSize = new Stochator({
mean: 4500,
@ -86,11 +87,9 @@ exports.make = function (startingMoment, endingMoment) {
'apache': 4
});
return _.transform(sets, function (note, set, name) {
if (name === 'days') {
return note[name] = set;
}
note[name] = _.bindKey(set, 'get');
}, {});
return _.mapValues(sets, function (set) {
return (typeof set === 'function') ? set : function () {
return set.get();
};
});
};

View File

@ -111,7 +111,7 @@ WeightedList.prototype._update = function () {
sum = 0,
totals = [];
_.each(me, function (item) {
me.forEach(function (item) {
sum += item.weight;
totals.push(sum);
});