0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-07 17:41:58 +00:00

Perf: Nicer output

This commit is contained in:
Jan Maria Matejka 2018-10-31 12:02:16 +01:00
parent d13fa8c0d3
commit 07d82fb52a
5 changed files with 26 additions and 12 deletions

View File

@ -3783,7 +3783,11 @@ any instance of Perf in production configs.
<tag><label id="perf-to">exp to <m/number/</tag> <tag><label id="perf-to">exp to <m/number/</tag>
Stop benchmarking on this exponent. Default: 20 Stop benchmarking on this exponent. Default: 20
<tag><label id="perf-threshold">threshold <m/time/</tag> <tag><label id="perf-threshold-min">threshold min <m/time/</tag>
If a run for the given exponent took less than this time for route import,
increase the exponent immediately. Default: 1 ms
<tag><label id="perf-threshold-max">threshold max <m/time/</tag>
If every run for the given exponent took at least this time for route import, If every run for the given exponent took at least this time for route import,
stop benchmarking. Default: 500 ms stop benchmarking. Default: 500 ms
</descrip> </descrip>

View File

@ -17,7 +17,7 @@ CF_DEFINES
CF_DECLS CF_DECLS
CF_KEYWORDS(PERF, EXP, FROM, TO, REPEAT, THRESHOLD, KEEP) CF_KEYWORDS(PERF, EXP, FROM, TO, REPEAT, THRESHOLD, MIN, MAX, KEEP)
CF_GRAMMAR CF_GRAMMAR
@ -29,7 +29,8 @@ perf_proto_start: proto_start PERF
PERF_CFG->from = 10; PERF_CFG->from = 10;
PERF_CFG->to = 20; PERF_CFG->to = 20;
PERF_CFG->repeat = 4; PERF_CFG->repeat = 4;
PERF_CFG->threshold = 500 MS_; PERF_CFG->threshold_max = 500 MS_;
PERF_CFG->threshold_min = 1 MS_;
PERF_CFG->keep = 0; PERF_CFG->keep = 0;
}; };
@ -43,7 +44,8 @@ perf_proto_item:
| EXP FROM NUM { PERF_CFG->from = $3; } | EXP FROM NUM { PERF_CFG->from = $3; }
| EXP TO NUM { PERF_CFG->to = $3; } | EXP TO NUM { PERF_CFG->to = $3; }
| REPEAT NUM { PERF_CFG->repeat = $2; } | REPEAT NUM { PERF_CFG->repeat = $2; }
| THRESHOLD expr_us { PERF_CFG->threshold = $2; } | THRESHOLD MIN expr_us { PERF_CFG->threshold_min = $3; }
| THRESHOLD MAX expr_us { PERF_CFG->threshold_max = $3; }
| KEEP bool { PERF_CFG->keep = $2; } | KEEP bool { PERF_CFG->keep = $2; }
; ;

View File

@ -120,11 +120,15 @@ sub draw {
my $csv = $self->dump(); my $csv = $self->dump();
my $svg = $self->stub . ".svg"; my $svg = $self->stub . ".svg";
my $title = $self->name;
$title =~ s/_/ /g;
open PLOT, "|-", "gnuplot -p"; open PLOT, "|-", "gnuplot -p";
print PLOT "set terminal svg;\n"; print PLOT "set terminal svg;\n";
print PLOT "set output '$svg';\n"; print PLOT "set output '$svg';\n";
print PLOT "set title '" . $self->name . "';\n"; print PLOT "set title '$title';\n";
print PLOT "set datafile separator ',';\n"; print PLOT "set datafile separator ',';\n";
print PLOT "set jitter over 0.3 spread 0.3;\n";
print PLOT "plot '$csv' using 1:2 title 'gen', '$csv' using 1:3 title 'temp', '$csv' using 1:4 title 'update', '$csv' using 1:5 title 'withdraw';\n"; print PLOT "plot '$csv' using 1:2 title 'gen', '$csv' using 1:3 title 'temp', '$csv' using 1:4 title 'update', '$csv' using 1:5 title 'withdraw';\n";
close PLOT; close PLOT;
} }

View File

@ -186,13 +186,14 @@ perf_loop(void *data)
s64 updatetime = timediff(&ts_rte, &ts_update); s64 updatetime = timediff(&ts_rte, &ts_update);
s64 withdrawtime = timediff(&ts_update, &ts_withdraw); s64 withdrawtime = timediff(&ts_update, &ts_withdraw);
PLOG("exp=%u times: gen=%lu temp=%lu update=%lu withdraw=%lu", if (updatetime NS >= p->threshold_min)
p->exp, gentime, temptime, updatetime, withdrawtime); PLOG("exp=%u times: gen=%lu temp=%lu update=%lu withdraw=%lu",
p->exp, gentime, temptime, updatetime, withdrawtime);
if (updatetime NS < p->threshold) if (updatetime NS < p->threshold_max)
p->stop = 0; p->stop = 0;
if (++p->run == p->repeat) { if ((updatetime NS < p->threshold_min) || (++p->run == p->repeat)) {
xfree(p->data); xfree(p->data);
p->data = NULL; p->data = NULL;
@ -222,7 +223,8 @@ perf_init(struct proto_config *CF)
struct perf_config *cf = (struct perf_config *) CF; struct perf_config *cf = (struct perf_config *) CF;
p->threshold = cf->threshold; p->threshold_min = cf->threshold_min;
p->threshold_max = cf->threshold_max;
p->from = cf->from; p->from = cf->from;
p->to = cf->to; p->to = cf->to;
p->repeat = cf->repeat; p->repeat = cf->repeat;

View File

@ -11,7 +11,8 @@
struct perf_config { struct perf_config {
struct proto_config p; struct proto_config p;
btime threshold; btime threshold_min;
btime threshold_max;
uint from; uint from;
uint to; uint to;
uint repeat; uint repeat;
@ -23,7 +24,8 @@ struct perf_proto {
struct ifa *ifa; struct ifa *ifa;
void *data; void *data;
event *loop; event *loop;
btime threshold; btime threshold_min;
btime threshold_max;
uint from; uint from;
uint to; uint to;
uint repeat; uint repeat;