例如,在上图中,foo1 调用堆栈显示为蓝色,表示原始性能剖析文件的 CPU 耗用量低于作为比较对象的性能剖析文件。帧 foo1 与其子帧 bar 相比,显示的蓝色更亮,这表示函数 foo1 与函数 bar 的指标耗用量存在较大差异。最后,foo2 调用堆栈显示为红色,表示原始性能剖析文件与作为比较对象的性能剖析文件相比,前者的 CPU 耗用量更高。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[],[],null,["# Compare profiles\n================\n\nCloud Profiler lets you visually compare two profiles of the same type,\ntaken from the same service within a project. You can compare profiles that\ndiffer by:\n\n- Ending times: Does the service run faster at certain times? Has there been a gradual improvement or decline over time?\n- Zones: Does the service run faster in some zones than in others?\n- Service versions: Do newer versions differ markedly from older ones? How?\n- Weight: How do profiles captured during high consumption periods differ from average profiles?\n\nSetting up a comparison\n-----------------------\n\nWhen you set up a comparison, you specify the parameters for\nan original profile and a compared profile. These two profiles share all\nconfiguration parameters except the one defined by the **Compare to**\nfield.\n\nTo configure a comparison, do the following:\n\n1. Set the comparison type by selecting an option from the **Compare to**\n menu:\n\n - [**End date/time**](/profiler/docs/selecting-profiles#time-config)\n - [**Zone**](/profiler/docs/selecting-profiles#zone-config)\n - [**Version**](/profiler/docs/selecting-profiles#version-config)\n - [**Weight**](/profiler/docs/selecting-profiles#weight-filter)\n\n Selecting one of these\n options results in a new configuration field. The field name\n begins with **Compared** and ends with the comparison type.\n For example, if you select **Version** , a **Compared version** field is\n displayed next to the **Compare to** field.\n2. Specify the compared profile by selecting an option from the\n **Compared** menu.\n\nFor example, the screenshot illustrates the settings to compare two versions\nof `docdemo-service`:\n\nThe settings for the following fields apply to the original profile and the\ncompared profile:\n\n- **Timespan** : `7 days`\n- **End time** : `10/24/19, 8:35 AM`\n- **Service** : `docdemo-service`\n- **Profile type** : `CPU time`\n- **Zone** : `All zones`\n- **Weight** : `All`\n\nFor the original profile, the **Version** is `1.75.0`. For the compared\nprofile, the **Version** is `1.25.0`.\n\nUnderstanding a comparison graph\n--------------------------------\n\nThe graph that results from a comparison differs from the standard graph\nin the following ways:\n\n- Meaning of colors\n- Meaning of function-block size\n- Metric information displayed by the tooltip\n- Contents of the focus list\n\n### Meaning of colors\n\nIn a standard flame graph, you can specify the color mode of the graph.\nFor more details, see [Color mode](/profiler/docs/filtering-profiles#color-filter).\n\nIn a comparison flame graph, the colors represent the difference\nbetween the total metric consumption of the function in the original profile\nand in the compared profile:\n\n- Gray: There is little or no difference.\n- Red: The difference is positive.\n- Blue: The difference is negative.\n\nThe larger the difference in consumption values between the two profiles\nbeing compared, the more saturated the color.\n\nFor example, in the previous figure, the\n`foo1` call stack is blue, indicating\nthat the original profile consumed *less* CPU than the compared profile.\nThe frame `foo1` is a brighter blue than its child frame `bar`, indicating that\nthere is a larger difference in metric consumption for the function `foo1`\nthan for the function `bar`.\nLastly, the `foo2` call stack is red, indicating that the\noriginal profile consumed *more* CPU than the compared profile.\n\n### Meaning of block size\n\nIn a standard flame graph, the size of the function blocks illustrates\nthe relative consumption of the metric being analyzed.\n\nIn a comparison flame graph, the size of the function blocks illustrates\nthe relative *average* consumption of the metric being analyzed.\nBy averaging the values for the two profiles, a block that exists only in\none profile still appears in the comparison graph, at half its pre-comparison\nsize.\n\n### Displayed metric values\n\nIn a standard flame graph, the metrics displayed by the tooltip are composed\nof two clauses, total and self. In both clauses, the absolute value is\ndisplayed along with a percentage: \n\n```\n total: 1.01 s, 28.8%; self: 1.01 s, 28.8%\n```\n\nIn a comparison flame graph, because there are two profiles being compared,\nthe tooltip displays the metric values for both profiles:\n\nAs shown in the figure, the total, and self clauses have the following form: \n\n```\n [ABS_ORIGINAL] vs. [ABS_COMPARED] ([ABS_DIFF]), [REL_ORIGINAL] vs. [REL_COMPARED] ([REL_DIFF])\n```\n\nIn this expression, `ABS_` means the absolute value and\n`REL_` means the relative percentage. Therefore, `[ABS_ORIGINAL]` is the\nabsolute value for\nthe original profile and `[ABS_COMPARED]` is the absolute value for the compared\nprofile. The field `[ABS_DIFF]`, defined as `[ABS_ORIGINAL]` - `[ABS_COMPARED]`,\nis the absolute difference between the two profiles. When\nthe absolute difference is zero, **no change** is displayed.\n\nThe percentage is computed for each profile as the ratio of a function's raw\nvalue to root's raw value. For example, in the original profile,\n`foo1` for took 4.67 seconds and `root` took 10.03 seconds. Therefore\n`[REL_ORIGINAL]` is about 46.0%. A similar computation is performed for the\ncompared profile. Lastly, the field `[REL_DIFF]`, defined as the difference of\nthese percentages, is the relative difference between the two profiles.\nWhen this difference is zero, **no change** is displayed.\n\nFor the preceding example, the total clause shows that the function `foo1` in\nthe original profile executes in 4.67 seconds. The absolute difference of\n-2.24 seconds indicates that `foo1` executes about 2.41 seconds\nfaster in the original profile than in the compared profile: \n\n```\n total: 4.67 s vs. 6.91 s (-2.24 s), 46.6% vs 69% (-22.4%)\n```\n\n### Focusing a comparison\n\nIn a standard flame graph, each row in the [Focus list](/profiler/docs/focusing-profiles#by_using_the_focus_list)\ncontains a function name, the self and total metric consumption values, and\nthe count of call stacks into that function.\n\nIn the comparison flame graph, each row in the [Focus list](/profiler/docs/focusing-profiles#by_using_the_focus_list)\ncontains a function name, the self and total metric consumption values, and\nthe count of call stacks into that function *for the original profile* .profiler\nFor a comparison flame graph, the focus list also includes\ntwo columns labeled **Diff** , a button labeled **Relative Diff** , and a\nbutton labeled **Absolute Diff** . For information on the relative difference\nand absolute difference, see [Displayed metric values](#diff-values).\n\nBy default, the color of the comparison flame graph is determined by the absolute\ndifferences between the original and compared profiles. In contrast, by default,\nthe focus list displays the relative differences between the two profiles\nbeing compared:\n\nThe table in the example shows that the function `foo1` takes about\n4.67 seconds to run in the original profile. The time 4.67 seconds corresponds\nto about 46.6% of the runtime. The **Diff** column, which displays the\nrelative difference, contains the value of `-22.4%`.\n\nTo view the absolute difference between metric values, click **Absolute Diff**.\n\nWhether you have a standard flame graph or a comparison flame graph,\nyou can sort the table rows in ascending *arrow_upward* or\ndescending *arrow_downward*\norder by selecting a table header element.\n\nTurning off comparison mode\n---------------------------\n\nTo turn off comparison mode, set the **Compare to** field to **None**.\n\nWhat's next\n-----------\n\n- [View historical trends](/profiler/docs/history-view).\n- [Download profile data](/profiler/docs/downloading-profiles)."]]