Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timing build time per subninja #1080

Closed
gioragutt opened this issue Dec 22, 2015 · 9 comments
Closed

Timing build time per subninja #1080

gioragutt opened this issue Dec 22, 2015 · 9 comments

Comments

@gioragutt
Copy link

I need to time how much time each subninja takes to build.

I've encountered 2 main problems:

  1. I can't really find a way to time a targets other then timing each command by wrapping it with a timing script.
  2. I can't link a rule to a certain subninja.

Would there be another way other then time each module?
&
Is there a way to export a $subninja as a variable, like $out?

Sincerely, giorag.

Edit: If adding this as a feature to ninja(timing each submodule build time) would be possible, it would be great!

@nicolasdespres
Copy link
Contributor

You could add a phony target (called sub_all for instance) depending on all the targets defined in your subninja file. Then for timing you can do: time ninja sub_all

@gioragutt
Copy link
Author

My target is not to time the whole build process, but to time each subninja seperately.
The purpose of it, eventually, is to figure out why some subninjas take longer than usual to build

@nicolasdespres
Copy link
Contributor

I think I got that. When you pass a target as argument to ninja (like sub_all) it builds only this target.

You can repeat this process for all your subninja.

@ilyapopov
Copy link

You can also have a look to .ninja_log file, which lists start and end times for all edges in first and second columns.

@gioragutt
Copy link
Author

Does it list it in all versions of ninja? My version of ninja is probably
1.3 or something...

2015-12-28 20:22 GMT+02:00 Ilya Popov notifications@github.com:

You can also have a look to .ninja_log file, which lists start and end
times for all edges in first and second columns.


Reply to this email directly or view it on GitHub
#1080 (comment).

@ilyapopov
Copy link

I just checked 1.3.4 and it does. What do you see in your .ninja_log? What does it say in the first line (which is comment)? Is it "# ninja log v5"?

@gioragutt
Copy link
Author

I'm currently not at my workplace, I'll return an answer tomorrow

2015-12-29 11:54 GMT+02:00 Ilya Popov notifications@github.com:

In 1.3.4 it does. What do you see in your .ninja_log? What does it say in
the first line (which is comment)? Is it "# ninja log v5"?


Reply to this email directly or view it on GitHub
#1080 (comment).

@nico
Copy link
Collaborator

nico commented Jan 4, 2016

See also https://groups.google.com/forum/#!topic/ninja-build/aD82sxwD3_o -- seems more like a support question than an issue in ninja itself, so closing this.

@nico nico closed this as completed Jan 4, 2016
@jktjkt
Copy link

jktjkt commented Oct 21, 2016

Here's some AWK stuff which shows per-target build time averaged through your build history.

#!/usr/bin/awk -f

!/^#/ {
    TIMES[$4] += ($2 - $1)/1000
    COUNT[$4] += 1
}

END {
    for (TGT in TIMES)
        AVG[TGT]=TIMES[TGT]/COUNT[TGT]
    asorti(AVG, SORTED, "@val_num_desc")
    for (num in SORTED)
        print AVG[SORTED[num]] " " SORTED[num]
}

After saving as, say, show-ninja-build-stats somewhere in your $PATH and chmod +x-ing it, you can simply run show-ninja-build-stats < .ninja_log in your build dir.

Thanks for that tip for checking this log file, @ilyapopov.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants