Small updates to hopefully correct reporter errors leading to lost memory.

This commit is contained in:
Seth Hall 2013-04-12 09:28:38 -04:00
parent a615601269
commit e93fd69cf2
4 changed files with 16 additions and 12 deletions

View file

@ -293,14 +293,19 @@ function add_data(id: string, key: Key, point: DataPoint)
key = r$normalize_key(copy(key)); key = r$normalize_key(copy(key));
local m = measurement_store[r$mid]; local m = measurement_store[r$mid];
local results = result_store[m$id];
if ( r$mid !in result_store )
result_store[m$id] = table();
local results = result_store[r$mid];
if ( key !in results ) if ( key !in results )
results[key] = table(); results[key] = table();
if ( id !in results[key] )
results[key][id] = init_resultval(r);
local result = results[key]; local result = results[key];
if ( id !in result )
result[id] = init_resultval(r);
local result_val = result[id]; local result_val = result[id];
++result_val$num; ++result_val$num;
# Continually update the $end field. # Continually update the $end field.
result_val$end=network_time(); result_val$end=network_time();

View file

@ -4,16 +4,16 @@
module Measurement; module Measurement;
export { export {
redef record Reducer += { redef record Reducer += {
## A number of sample DataPoints to collect. ## A number of sample DataPoints to collect.
samples: count &default=0; samples: count &default=0;
}; };
redef record ResultVal += { redef record ResultVal += {
# This is the queue where samples ## This is the queue where samples
# are maintained. Use the :bro:see:`Measurement::get_samples` ## are maintained. Use the
## function to get a vector of the samples. ## :bro:see:`Measurement::get_samples` function
## to get a vector of the samples.
samples: Queue::Queue &optional; samples: Queue::Queue &optional;
}; };

View file

@ -11,7 +11,7 @@ export {
redef record ResultVal += { redef record ResultVal += {
## For numeric data, this calculates the standard deviation. ## For numeric data, this calculates the standard deviation.
std_dev: double &optional; std_dev: double &default=0.0;
}; };
} }
@ -28,8 +28,6 @@ hook add_to_reducer_hook(r: Reducer, val: double, data: DataPoint, rv: ResultVal
{ {
if ( rv?$variance ) if ( rv?$variance )
calc_std_dev(rv); calc_std_dev(rv);
else
rv$std_dev = 0.0;
} }
} }

View file

@ -44,7 +44,8 @@ hook add_to_reducer_hook(r: Reducer, val: double, data: DataPoint, rv: ResultVal
# Reduced priority since this depends on the average # Reduced priority since this depends on the average
hook compose_resultvals_hook(result: ResultVal, rv1: ResultVal, rv2: ResultVal) &priority=-5 hook compose_resultvals_hook(result: ResultVal, rv1: ResultVal, rv2: ResultVal) &priority=-5
{ {
if ( rv1?$var_s && rv2?$var_s ) if ( rv1?$var_s && rv1?$average &&
rv2?$var_s && rv2?$average )
{ {
local rv1_avg_sq = (rv1$average - result$average); local rv1_avg_sq = (rv1$average - result$average);
rv1_avg_sq = rv1_avg_sq*rv1_avg_sq; rv1_avg_sq = rv1_avg_sq*rv1_avg_sq;