On Mon, Mar 11, 2019 at 11:19:03AM +0300, Alexey Budankov wrote:
> On 07.03.2019 11:29, Alexey Budankov wrote:
> > 
> > On 05.03.2019 15:26, Jiri Olsa wrote:
> >> On Fri, Mar 01, 2019 at 06:43:28PM +0300, Alexey Budankov wrote:
> >>>
> >>> Define bytes_transferred and bytes_compressed metrics to calculate
> >>> comp_ratio=transferred/compressed in the end of the data collection.
> >>>
> >>> bytes_transferred accumulates the amount of bytes that was extracted from
> >>> the mmaped kernel buffers for compression. bytes_compressed accumulates
> >>> the amount of bytes that was received after applying compression to
> >>> move to a storage.
> >>>
> >>> Signed-off-by: Alexey Budankov <[email protected]>
> >>> ---
> >>>  tools/perf/builtin-record.c | 8 ++++++++
> >>>  tools/perf/util/env.h       | 1 +
> >>>  tools/perf/util/session.h   | 2 ++
> >>>  3 files changed, 11 insertions(+)
> >>>
> >>> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> >>> index 9b02a68e8c23..ab121bc27c6d 100644
> >>> --- a/tools/perf/builtin-record.c
> >>> +++ b/tools/perf/builtin-record.c
> >>> @@ -1449,6 +1449,14 @@ static int __cmd_record(struct record *rec, int 
> >>> argc, const char **argv)
> >>>   record__mmap_read_all(rec, true);
> >>>   record__aio_mmap_read_sync(rec);
> >>>  
> >>> + if (!quiet && rec->session->bytes_transferred && 
> >>> rec->session->bytes_compressed) {
> >>> +         float ratio = 
> >>> (float)rec->session->bytes_transferred/(float)rec->session->bytes_compressed;
> >>> +
> >>> +         session->header.env.comp_ratio = ratio + 0.5;
> >>
> >> what's the + 0.5 for?
> > 
> > Arithmetic rounding before type cast.
> > 
> >>
> >>> +         fprintf(stderr, "[ perf record: Compressed %.3f MB to %.3f MB, 
> >>> ratio is %.3f ]\n",
> >>> +                 rec->session->bytes_transferred / 1024.0 / 1024.0, 
> >>> rec->session->bytes_compressed / 1024.0 / 1024.0, ratio);
> >>> + }
> >>> +
> >>
> >> could this be below together with the current:
> >>
> >>    fprintf(stderr, "[ perf record: Captured and wrote %.3f MB %s%s%s ]\n",
> > 
> > Please provide an example of what you exactly mean.
> 
> It could look like this:
> 
> [ perf record: Woken up 101 times to write data ]
> [ perf record: Captured and wrote 5.173 MB perf.data (714077 samples), 
> compressed 27.241 MB to 5.160 MB, ratio is 5.279 ]

yes, maybe we don't need to repeat the original size twice:

[ perf record: Captured and wrote 5.173 MB perf.data (714077 samples), 
compressed (original 27.241 MB, ratio 5.279) ]

jirka

Reply via email to