diff mbox series

[FFmpeg-devel,1/7] checkasm: add csv/tsv bench output

Message ID 20240813140338.143045-1-jdek@itanimul.li
State New
Headers show
Series [FFmpeg-devel,1/7] checkasm: add csv/tsv bench output | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

J. Dekker Aug. 13, 2024, 2:03 p.m. UTC
When collecting performance information from checkasm it is common
to parse the output for use in graphs to compare vs different
architectures.

Signed-off-by: J. Dekker <jdek@itanimul.li>
---
 tests/checkasm/checkasm.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

Comments

Anton Khirnov Aug. 16, 2024, 11:03 a.m. UTC | #1
Quoting J. Dekker (2024-08-13 16:03:30)
> When collecting performance information from checkasm it is common
> to parse the output for use in graphs to compare vs different
> architectures.
> 
> Signed-off-by: J. Dekker <jdek@itanimul.li>
> ---
>  tests/checkasm/checkasm.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)

Is TSV a standard acronym? I've never seen it before.
And would it make sense to allow specifying an arbitrary separator
string?
J. Dekker Aug. 16, 2024, 2:39 p.m. UTC | #2
On Fri, Aug 16, 2024, at 13:03, Anton Khirnov wrote:
> Quoting J. Dekker (2024-08-13 16:03:30)
>> When collecting performance information from checkasm it is common
>> to parse the output for use in graphs to compare vs different
>> architectures.
>> 
>> Signed-off-by: J. Dekker <jdek@itanimul.li>
>> ---
>>  tests/checkasm/checkasm.c | 22 ++++++++++++++++++++--
>>  1 file changed, 20 insertions(+), 2 deletions(-)
>
> Is TSV a standard acronym? I've never seen it before.
> And would it make sense to allow specifying an arbitrary separator
> string?

I think TSV is understood within the context of CSV. Initially I was going to just have only the ‘standard’ CSV but I would personally prefer a whitespace separator like <TAB> (I have seen the ASCII control characters used too). I don’t think that it would make sense to support any further arbitrary characters since you can s/\t/<sep>/g.

jd
Rémi Denis-Courmont Aug. 16, 2024, 3:03 p.m. UTC | #3
Le 16 août 2024 14:03:01 GMT+03:00, Anton Khirnov <anton@khirnov.net> a écrit :
>Quoting J. Dekker (2024-08-13 16:03:30)
>> When collecting performance information from checkasm it is common
>> to parse the output for use in graphs to compare vs different
>> architectures.
>> 
>> Signed-off-by: J. Dekker <jdek@itanimul.li>
>> ---
>>  tests/checkasm/checkasm.c | 22 ++++++++++++++++++++--
>>  1 file changed, 20 insertions(+), 2 deletions(-)
>
>Is TSV a standard acronym? I've never seen it before.

Me neither.

>And would it make sense to allow specifying an arbitrary separator
>string?

Sounds a bit overkill.
Ramiro Polla Aug. 18, 2024, 2:43 p.m. UTC | #4
On Tue, Aug 13, 2024 at 4:03 PM J. Dekker <jdek@itanimul.li> wrote:
> When collecting performance information from checkasm it is common
> to parse the output for use in graphs to compare vs different
> architectures.
>
> Signed-off-by: J. Dekker <jdek@itanimul.li>
> ---

When I redirect stdout to a csv file, the first two lines are:
benchmarking with Linux Perf Monitoring API
nop: 70.0

What about printing those to stderr when csv is enabled?
diff mbox series

Patch

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 58597d3888..f82ee0864f 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -362,6 +362,8 @@  static struct {
     const char *cpu_flag_name;
     const char *test_name;
     int verbose;
+    int csv;
+    int tsv;
     volatile sig_atomic_t catch_signals;
 } state;
 
@@ -586,7 +588,14 @@  static void print_benchs(CheckasmFunc *f)
                 CheckasmPerf *p = &v->perf;
                 if (p->iterations) {
                     int decicycles = (10*p->cycles/p->iterations - state.nop_time) / 4;
-                    printf("%s_%s: %d.%d\n", f->name, cpu_suffix(v->cpu), decicycles/10, decicycles%10);
+                    if (state.csv) {
+                        const char sep = state.tsv ? '\t' : ',';
+                        printf("%s%c%s%c%d.%d\n", f->name, sep,
+                               cpu_suffix(v->cpu), sep,
+                               decicycles / 10, decicycles % 10);
+                    } else {
+                        printf("%s_%s: %d.%d\n", f->name, cpu_suffix(v->cpu), decicycles/10, decicycles%10);
+                    }
                 }
             } while ((v = v->next));
         }
@@ -829,7 +838,12 @@  static void bench_uninit(void)
 static int usage(const char *path)
 {
     fprintf(stderr,
-            "Usage: %s [--bench] [--runs=<ptwo>] [--test=<pattern>] [--verbose] [seed]\n",
+            "Usage: %s [options...] [seed]\n"
+            "  --test=<pattern> Run specific test.\n"
+            "  --bench          Run benchmark.\n"
+            "  --csv, --tsv     Output benchmark results in CSV or TSV format.\n"
+            "  --runs=<ptwo>    Manual number of benchmark iterations to run 2**<ptwo>.\n"
+            "  --verbose        Increase verbosity.\n",
             path);
     return 1;
 }
@@ -877,6 +891,10 @@  int main(int argc, char *argv[])
                 state.bench_pattern = "";
         } else if (!strncmp(arg, "--test=", 7)) {
             state.test_name = arg + 7;
+        } else if (!strcmp(arg, "--csv")) {
+            state.csv = 1; state.tsv = 0;
+        } else if (!strcmp(arg, "--tsv")) {
+            state.csv = 1; state.tsv = 1;
         } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
             state.verbose = 1;
         } else if (!strncmp(arg, "--runs=", 7)) {