mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
profile: produce civilized output
This commit is contained in:
parent
99a7b69578
commit
dd1ee39271
@ -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() {
|
pub fn (mut g Gen) gen_vprint_profile_stats() {
|
||||||
g.pcs_declarations.writeln('void vprint_profile_stats(){')
|
g.pcs_declarations.writeln('void vprint_profile_stats(){')
|
||||||
|
fstring := '"%14llu %14.3fms %14.0fns %s \\n"'
|
||||||
if g.pref.profile_file == '-' {
|
if g.pref.profile_file == '-' {
|
||||||
for pc_meta in g.pcs {
|
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 {
|
} else {
|
||||||
g.pcs_declarations.writeln('\tFILE * fp;')
|
g.pcs_declarations.writeln('\tFILE * fp;')
|
||||||
g.pcs_declarations.writeln('\tfp = fopen ("${g.pref.profile_file}", "w+");')
|
g.pcs_declarations.writeln('\tfp = fopen ("${g.pref.profile_file}", "w+");')
|
||||||
for pc_meta in g.pcs {
|
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);')
|
g.pcs_declarations.writeln('\tfclose(fp);')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user