[Gprof显示了应用程序中的常规功能,如

问题描述 投票:4回答:1

所以-我已经将语言解释器作为副项目编写了一年。今天,我终于决定第一次测试它的性能!也许我应该早点做一下……事实证明,使用该语言运行Fibonacci函数所需的时间是等效Python程序的x600。黛西。

无论如何...我要进行概要分析。在调用图中,gprof视为从<spontaneous>调用的一些功能(即关键功能)。这是一个问题,因为了解最常调用这些功能的内容将对我有帮助。

我像这样编译整个项目:

gcc *.c -o app.exe -g -pg -O2 -Wall -Wno-unused -LC:/msys64_new/mingw64/lib -lShlwapi

我像这样使用gprof

gprof app.exe > gprofoutput.txt

由于它是语言解释器,因此其中许多功能(全部?)可能被称为相互递归链的一部分。这可能是问题所在吗?如果是这样,gprof是否可以完全信任此程序?

<spontaneous>调用的函数被编译为项目的*.c文件的一部分,并且未被外部库或我所知的任何东西调用。

因为我已经检查了这一点,所以此处关于<spontaneous>的其他答案还没有解决我的问题。是什么导致这些功能显示为<spontaneous>中的调用,如何解决此问题?

示例gprof输出(_mcount_private__fentry__当然是不相关的-如果可以提供任何线索,请在此处包括它们:]

index % time    self  children    called     name
                                                 <spontaneous>
[1]     46.9    1.38    0.00                 _mcount_private [1]
-----------------------------------------------
                                                 <spontaneous>
[2]     23.1    0.68    0.00                 __fentry__ [2]
-----------------------------------------------
                                                 <spontaneous>
[3]     18.7    0.06    0.49                 object_string_new [3]
                0.17    0.24 5687901/5687901     cell_table_set_value [4]
                0.00    0.08 5687901/7583875     make_native_function_with_params [7]
                0.00    0.00 13271769/30578281     parser_parse [80]
-----------------------------------------------
                0.17    0.24 5687901/5687901     object_string_new [3]
[4]     14.1    0.17    0.24 5687901         cell_table_set_value [4]
                0.12    0.05 5687901/5930697     table_set_value_directly [6]
                0.02    0.04 5687901/7341054     table_get_value_directly [9]
                0.01    0.00 5687901/5930694     object_cell_new [31]
-----------------------------------------------
                                                 <spontaneous>
[5]      7.0    0.07    0.14                 vm_interpret_frame [5]
                0.01    0.05 1410341/1410345     cell_table_get_value_cstring_key [13]
                0.01    0.02  242786/242794      cell_table_set_value_cstring_key [19]
                0.02    0.00 3259885/3502670     object_thread_pop_eval_stack [22]
                0.01    0.00  242785/242786      value_array_free [28]
                0.00    0.01  242785/242785      vm_call_object [34]
                0.00    0.00  681987/1849546     value_compare [32]
                0.00    0.00  485570/31306651     table_init [20]
                0.00    0.00  242785/242788      cell_table_free [38]
                0.00    0.00  242785/25375951     cell_table_init [29]
                0.00    0.00       1/1           object_load_attribute [50]
                0.00    0.00       1/1           object_load_attribute_cstring_key [52]
                0.00    0.00       1/2           object_user_function_new [56]
                0.00    0.00       2/33884613     copy_cstring [17]
                0.00    0.00       1/5687909     object_function_set_name [25]
                0.00    0.00       1/17063722     copy_null_terminated_cstring [23]
                0.00    0.00       1/72532402     allocate [21]
                0.00    0.00 3502671/3502671     object_thread_push_eval_stack [81]
                0.00    0.00 1167557/1167557     object_as_string [85]
                0.00    0.00  681988/681995      two_bytes_to_short [86]
                0.00    0.00  485572/485578      value_array_make [88]
                0.00    0.00  242786/242786      object_thread_push_frame [96]
                0.00    0.00  242786/242786      object_thread_peek_frame [95]
                0.00    0.00  242785/242785      object_thread_pop_frame [97]
                0.00    0.00  242785/485571      vm_import_module [89]
                0.00    0.00       2/1167575     object_value_is [83]
-----------------------------------------------

..... etc .........

我正在Windows 7上运行Mingw-w64 GCC。

c profiling gprof
1个回答
2
投票

来自the gprof manual

如果无法确定函数调用者的身份,则将打印一条虚拟的呼叫者行,该行以''作为“呼叫者名称”,所有其他字段为空。对于信号处理程序,可能会发生这种情况。

似乎gprof不知道您呼叫者的名字。如果任何潜在的调用方(包括异步调度,如果您正在使用的话)被编译为没有符号,则调用方名称将为未知。您正在使用哪些第三方库?您可以为其获取调试符号吗?

您可以获取Windows symbol packages,尽管我不知道涵盖哪些库。该页面还讨论了如何使用Microsoft的Symbol Server而不是下载(可能已过期)符号包。

© www.soinside.com 2019 - 2024. All rights reserved.