and another option for the benchmark reader (constant addition of lines)

This commit is contained in:
Bernhard Amann 2012-03-28 09:35:45 -07:00
parent 579a10d060
commit ed5374b6d7
4 changed files with 18 additions and 0 deletions

View file

@ -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;
}

View file

@ -50,3 +50,4 @@ module InputBenchmark;
const factor: double;
const spread: count;
const autospread: double;
const addfactor: count;

View file

@ -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:
@ -231,6 +233,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) );
// because executing this in every loop is apparently too expensive.

View file

@ -42,6 +42,7 @@ private:
int spread;
double autospread;
int autospread_time;
int add;
string RandomString(const int len);