From dd1ee39271432b147ee6ad0414a16a8096bdb64c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 27 Apr 2020 12:45:19 +0300 Subject: [PATCH] profile: produce civilized output --- vlib/v/gen/profile.v | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/profile.v b/vlib/v/gen/profile.v index ad258a5286..07b49c1938 100644 --- a/vlib/v/gen/profile.v +++ b/vlib/v/gen/profile.v @@ -29,15 +29,16 @@ fn (mut g Gen) profile_fn(fn_name string, is_main bool){ pub fn (mut g Gen) gen_vprint_profile_stats() { g.pcs_declarations.writeln('void vprint_profile_stats(){') + fstring := '"%14llu %14.3fms %14.0fns %s \\n"' if g.pref.profile_file == '-' { for pc_meta in g.pcs { - g.pcs_declarations.writeln('\tif (${pc_meta.vpc_calls}) printf("%llu %f %f ${pc_meta.fn_name} \\n", ${pc_meta.vpc_calls}, ${pc_meta.vpc_name}, ${pc_meta.vpc_name}/${pc_meta.vpc_calls} );') + g.pcs_declarations.writeln('\tif (${pc_meta.vpc_calls}) printf($fstring, ${pc_meta.vpc_calls}, ${pc_meta.vpc_name}/1000000.0, ${pc_meta.vpc_name}/${pc_meta.vpc_calls}, "${pc_meta.fn_name}" );') } } else { g.pcs_declarations.writeln('\tFILE * fp;') g.pcs_declarations.writeln('\tfp = fopen ("${g.pref.profile_file}", "w+");') for pc_meta in g.pcs { - g.pcs_declarations.writeln('\tif (${pc_meta.vpc_calls}) fprintf(fp, "%llu %f %f ${pc_meta.fn_name} \\n", ${pc_meta.vpc_calls}, ${pc_meta.vpc_name}, ${pc_meta.vpc_name}/${pc_meta.vpc_calls} );') + g.pcs_declarations.writeln('\tif (${pc_meta.vpc_calls}) fprintf(fp, $fstring, ${pc_meta.vpc_calls}, ${pc_meta.vpc_name}/1000000.0, ${pc_meta.vpc_name}/${pc_meta.vpc_calls}, "${pc_meta.fn_name}" );') } g.pcs_declarations.writeln('\tfclose(fp);') }