C++ gprof 表示 main 仅使用约 20% 的时间

发布于 2024-09-08 13:35:33 字数 1455 浏览 0 评论 0原文

我尝试使用 gprof 分析我的 C++ 程序。程序本身运行了大约53秒,所以我不明白为什么它说,main只运行了大约8.29秒。对此有何解释?

以下是摘录:

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]

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]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一紙繁鸢 2024-09-15 13:35:33

您是否将结果打印到控制台? gprof 不计算阻塞时间。 请参阅此内容。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文