简体   繁体   中英

C++ main only uses ~20% time says gprof

I tried profiling my C++ program with gprof. The program itself ran for about 53 seconds, so I dont understand why it says, main only ran for about 8.29 seconds. Any explanation on this?

Here is an excerpt:

index % time    self  children    called     name
                                                 <spontaneous>
[2]     20.5    0.00    8.29                 main [2]
                0.00    8.28       1/1           MPQS::start(std::basic_ofstream<char, std::char_traits<char> >&) [3]
                0.00    0.01       1/1           MPQS::MPQS(NTL::ZZ, long) [36]
                0.00    0.00       1/1           MPQS::~MPQS() [78]
-----------------------------------------------
                0.00    8.28       1/1           main [2]
[3]     20.5    0.00    8.28       1         MPQS::start(std::basic_ofstream<char, std::char_traits<char> >&) [3]
                7.15    1.08     801/801         MPQS::sieve() [4]
                0.00    0.04     801/801         MPQS::find_smooth_vals() [23]
                0.01    0.00       1/1           MPQS::try_solutions(NTL::mat_GF2&) [35]
                0.00    0.00     801/801         MPQS::compute_coeffecients() [59]
-----------------------------------------------
                7.15    1.08     801/801         MPQS::start(std::basic_ofstream<char, std::char_traits<char> >&) [3]
[4]     20.4    7.15    1.08     801         MPQS::sieve() [4]
                1.08    0.00     801/801         MPQS::find_candidates() [9]

Were you printing results to the console? gprof doesn't count blocked time. See this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM