diff --git a/scripts/base/frameworks/input/readers/benchmark.bro b/scripts/base/frameworks/input/readers/benchmark.bro index c6a6e88fca..0f3553b117 100644 --- a/scripts/base/frameworks/input/readers/benchmark.bro +++ b/scripts/base/frameworks/input/readers/benchmark.bro @@ -11,4 +11,7 @@ export { ## spreading where usleep = 1000000 / autospread * num_lines const autospread = 0.0 &redef; + + ## addition factor for each heartbeat + const addfactor = 0 &redef; } diff --git a/src/input.bif b/src/input.bif index 059a7ec8bf..798759ab66 100644 --- a/src/input.bif +++ b/src/input.bif @@ -50,3 +50,4 @@ module InputBenchmark; const factor: double; const spread: count; const autospread: double; +const addfactor: count; diff --git a/src/input/readers/Benchmark.cc b/src/input/readers/Benchmark.cc index d8de8c2538..a17c8a7ff6 100644 --- a/src/input/readers/Benchmark.cc +++ b/src/input/readers/Benchmark.cc @@ -24,6 +24,7 @@ Benchmark::Benchmark(ReaderFrontend *frontend) : ReaderBackend(frontend) multiplication_factor = double(BifConst::InputBenchmark::factor); autospread = double(BifConst::InputBenchmark::autospread); spread = int(BifConst::InputBenchmark::spread); + add = int(BifConst::InputBenchmark::addfactor); autospread_time = 0; } @@ -213,6 +214,7 @@ bool Benchmark::DoHeartbeat(double network_time, double current_time) { ReaderBackend::DoHeartbeat(network_time, current_time); num_lines = (int) ( (double) num_lines*multiplication_factor); + num_lines += add; switch ( mode ) { case MANUAL: @@ -230,6 +232,17 @@ bool Benchmark::DoHeartbeat(double network_time, double current_time) SendEvent("lines_changed", 2, v); } + + if ( add != 0 ) { + // we have to document at what time we changed the factor to what value. + Value** v = new Value*[2]; + v[0] = new Value(TYPE_COUNT, true); + v[0]->val.uint_val = num_lines; + v[1] = new Value(TYPE_TIME, true); + v[1]->val.double_val = CurrTime(); + + SendEvent("lines_changed", 2, v); + } if ( autospread != 0.0 ) { autospread_time = (int) ( (double) 1000000 / (autospread * (double) num_lines) ); diff --git a/src/input/readers/Benchmark.h b/src/input/readers/Benchmark.h index f0bd0c752d..182adcd1af 100644 --- a/src/input/readers/Benchmark.h +++ b/src/input/readers/Benchmark.h @@ -42,6 +42,7 @@ private: int spread; double autospread; int autospread_time; + int add; string RandomString(const int len);