plot icon indicating copy to clipboard operation
plot copied to clipboard

Generic Parsing

Open annacrombie opened this issue 4 years ago • 2 comments

(copied/editied from second half of #13)

Generic Parsing

Motivation

Many counters exposed to userspace by the linux kernel are exported as a file that is not simply a file with a number in it, but has either 1. multiple counters or 2 with surrounding text. Many files exposed via /proc/ are examples of this.

Presently plot expects the input value that it receives (stdout or file) to be a number represented as a string that can be converted to a double via strtod().

It would be really nice if plot supported a generic parsing functionality for extracting numbers from text. What I have in mind is adding an option where one could specify a name for a parser in C that is either provided, or custom-written.

annacrombie avatar Mar 08 '21 00:03 annacrombie

I haven't had a chance to work on this lately, though I have been thinking about ways to implement it. I'll try to put something together in the next week or two.

holmanb avatar Mar 16 '21 05:03 holmanb

By the way, it should be easier to implement now, as all the processing and rendering is completely isolated from the actual input. See here for an example of the new callback-based api

I need to write some docs for it, but basically the callback takes this form:

uint32_t plot_input_func(void *ctx, double *out, uint32_t out_max);

It is the callback's job to fill in the out array with elements. out_max is the maximum number of elements that can be filled (but filling in less is OK). The return value should be how many elements were actually filled. ctx is a user pointer that gets set in plot_dataset_init.

annacrombie avatar Mar 17 '21 00:03 annacrombie