mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +00:00
most of the stuff we should need for benchmarking. next: search memory leaks, after 1.5million simulated
inputs we are leaking about 1Gb of ram...
This commit is contained in:
parent
28f3fa0144
commit
355b85fcd7
6 changed files with 34 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
@load ./main
|
||||
@load ./readers/ascii
|
||||
@load ./readers/raw
|
||||
@load ./readers/benchmark
|
||||
|
||||
|
|
8
scripts/base/frameworks/input/readers/benchmark.bro
Normal file
8
scripts/base/frameworks/input/readers/benchmark.bro
Normal file
|
@ -0,0 +1,8 @@
|
|||
##! Interface for the ascii input reader.
|
||||
|
||||
module InputBenchmark;
|
||||
|
||||
export {
|
||||
## multiplication factor for each second
|
||||
const factor = 1 &redef;
|
||||
}
|
|
@ -45,3 +45,6 @@ const unset_field: string;
|
|||
|
||||
module InputRaw;
|
||||
const record_separator: string;
|
||||
|
||||
module InputBenchmark;
|
||||
const factor: count;
|
||||
|
|
|
@ -58,7 +58,12 @@ public:
|
|||
name(name), num_vals(num_vals), val(val) {}
|
||||
|
||||
virtual bool Process() {
|
||||
return input_mgr->SendEvent(name, num_vals, val);
|
||||
bool success = input_mgr->SendEvent(name, num_vals, val);
|
||||
|
||||
if ( !success )
|
||||
reporter->Error("SendEvent for event %s failed", name.c_str());
|
||||
|
||||
return true; // we do not want to die if sendEvent fails because the event did not return.
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -21,6 +21,7 @@ using threading::Field;
|
|||
|
||||
Benchmark::Benchmark(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||
{
|
||||
multiplication_factor = int(BifConst::InputBenchmark::factor);
|
||||
}
|
||||
|
||||
Benchmark::~Benchmark()
|
||||
|
@ -198,13 +199,25 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype) {
|
|||
bool Benchmark::DoHeartbeat(double network_time, double current_time)
|
||||
{
|
||||
ReaderBackend::DoHeartbeat(network_time, current_time);
|
||||
|
||||
num_lines = num_lines*multiplication_factor;
|
||||
|
||||
switch ( mode ) {
|
||||
case MANUAL:
|
||||
// yay, we do nothing :)
|
||||
break;
|
||||
case REREAD:
|
||||
case STREAM:
|
||||
if ( multiplication_factor != 1 ) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
Update(); // call update and not DoUpdate, because update actually checks disabled.
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -38,6 +38,8 @@ private:
|
|||
int mode;
|
||||
int num_lines;
|
||||
|
||||
int multiplication_factor;
|
||||
|
||||
string RandomString(const int len);
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue