gnuplot output: Optimize by only storing changes.
Only output new lines in gnuplot output if there have been changes in the samples (similar to what VCD does). As long as the first and last sample are output, the resulting plot looks OK. This reduces the size of the output file from roughly 200MB to just 60KB in one specific test setup (depends on the number of probes and on the signal, of course). The time and CPU load required to generate the gnuplot output and the resulting plot (PNG or other) is also drastically reduced from multiple minutes to roughly 30 seconds (again, depends on various things). Thanks Ken Mobley of ChronoVu for the report.
This commit is contained in:
parent
15f2d0c0f2
commit
50959ddcdc
|
@ -195,7 +195,7 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
|
||||||
struct context *ctx;
|
struct context *ctx;
|
||||||
unsigned int max_linelen, outsize, p, curbit, i;
|
unsigned int max_linelen, outsize, p, curbit, i;
|
||||||
uint64_t sample;
|
uint64_t sample;
|
||||||
static uint64_t samplecount = 0;
|
static uint64_t samplecount = 0, old_sample = 0;
|
||||||
char *outbuf, *c;
|
char *outbuf, *c;
|
||||||
|
|
||||||
if (!o) {
|
if (!o) {
|
||||||
|
@ -243,8 +243,19 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i <= length_in - ctx->unitsize; i += ctx->unitsize) {
|
for (i = 0; i <= length_in - ctx->unitsize; i += ctx->unitsize) {
|
||||||
|
|
||||||
memcpy(&sample, data_in + i, ctx->unitsize);
|
memcpy(&sample, data_in + i, ctx->unitsize);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't output the same samples multiple times. However, make
|
||||||
|
* sure to output at least the first and last sample.
|
||||||
|
*/
|
||||||
|
if (samplecount++ != 0 && sample == old_sample) {
|
||||||
|
if (i != (length_in - ctx->unitsize))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
old_sample = sample;
|
||||||
|
|
||||||
/* The first column is a counter (needed for gnuplot). */
|
/* The first column is a counter (needed for gnuplot). */
|
||||||
c = outbuf + strlen(outbuf);
|
c = outbuf + strlen(outbuf);
|
||||||
sprintf(c, "%" PRIu64 "\t", samplecount++);
|
sprintf(c, "%" PRIu64 "\t", samplecount++);
|
||||||
|
|
Loading…
Reference in New Issue