Compare profiles

Cloud Profiler lets you visually compare two profiles of the same type,taken from the same service within a project. You can compare profiles thatdiffer by:

  • Ending times: Does the service run faster at certain times? Has there beena gradual improvement or decline over time?
  • Zones: Does the service run faster in some zones than in others?
  • Service versions: Do newer versions differ markedly from older ones? How?
  • Weight: How do profiles captured during high consumption periodsdiffer from average profiles?

Setting up a comparison

When you set up a comparison, you specify the parameters foran original profile and a compared profile. These two profiles share allconfiguration parameters except the one defined by theCompare tofield.

To configure a comparison, do the following:

  1. Set the comparison type by selecting an option from theCompare tomenu:

    Selecting one of theseoptions results in a new configuration field. The field namebegins withCompared and ends with the comparison type.For example, if you selectVersion, aCompared version field isdisplayed next to theCompare to field.

  2. Specify the compared profile by selecting an option from theCompared menu.

For example, the screenshot illustrates the settings to compare two versionsofdocdemo-service:

Comparison of two CPU-time profiles.

The settings for the following fields apply to the original profile and thecompared profile:

  • Timespan:7 days
  • End time:10/24/19, 8:35 AM
  • Service:docdemo-service
  • Profile type:CPU time
  • Zone:All zones
  • Weight:All

For the original profile, theVersion is1.75.0. For the comparedprofile, theVersion is1.25.0.

Understanding a comparison graph

The graph that results from a comparison differs from the standard graphin the following ways:

  • Meaning of colors
  • Meaning of function-block size
  • Metric information displayed by the tooltip
  • Contents of the focus list

Meaning of colors

In a standard flame graph, you can specify the color mode of the graph.For more details, seeColor mode.

In a comparison flame graph, the colors represent the differencebetween the total metric consumption of the function in the original profileand in the compared profile:

  • Gray: There is little or no difference.
  • Red: The difference is positive.
  • Blue: The difference is negative.

The larger the difference in consumption values between the two profilesbeing compared, the more saturated the color.

For example, in the previous figure, thefoo1 call stack is blue, indicatingthat the original profile consumedless CPU than the compared profile.The framefoo1 is a brighter blue than its child framebar, indicating thatthere is a larger difference in metric consumption for the functionfoo1than for the functionbar.Lastly, thefoo2 call stack is red, indicating that theoriginal profile consumedmore CPU than the compared profile.

Meaning of block size

In a standard flame graph, the size of the function blocks illustratesthe relative consumption of the metric being analyzed.

In a comparison flame graph, the size of the function blocks illustratesthe relativeaverage consumption of the metric being analyzed.By averaging the values for the two profiles, a block that exists only inone profile still appears in the comparison graph, at half its pre-comparisonsize.

Displayed metric values

In a standard flame graph, the metrics displayed by the tooltip are composedof two clauses, total and self. In both clauses, the absolute value isdisplayed along with a percentage:

     total: 1.01 s, 28.8%; self: 1.01 s, 28.8%

In a comparison flame graph, because there are two profiles being compared,the tooltip displays the metric values for both profiles:

Values displayed in a profile comparison.

As shown in the figure, the total, and self clauses have the following form:

     [ABS_ORIGINAL] vs. [ABS_COMPARED] ([ABS_DIFF]), [REL_ORIGINAL] vs. [REL_COMPARED] ([REL_DIFF])

In this expression,ABS_ means the absolute value andREL_ means the relative percentage. Therefore,[ABS_ORIGINAL] is theabsolute value forthe original profile and[ABS_COMPARED] is the absolute value for the comparedprofile. The field[ABS_DIFF], defined as[ABS_ORIGINAL] -[ABS_COMPARED],is the absolute difference between the two profiles. Whenthe absolute difference is zero,no change is displayed.

The percentage is computed for each profile as the ratio of a function's rawvalue to root's raw value. For example, in the original profile,foo1 for took 4.67 seconds androot took 10.03 seconds. Therefore[REL_ORIGINAL] is about 46.0%. A similar computation is performed for thecompared profile. Lastly, the field[REL_DIFF], defined as the difference ofthese percentages, is the relative difference between the two profiles.When this difference is zero,no change is displayed.

For the preceding example, the total clause shows that the functionfoo1 inthe original profile executes in 4.67 seconds. The absolute difference of-2.24 seconds indicates thatfoo1 executes about 2.41 secondsfaster in the original profile than in the compared profile:

     total: 4.67 s vs. 6.91 s (-2.24 s), 46.6% vs 69% (-22.4%)

Focusing a comparison

In a standard flame graph, each row in theFocus listcontains a function name, the self and total metric consumption values, andthe count of call stacks into that function.

In the comparison flame graph, each row in theFocus listcontains a function name, the self and total metric consumption values, andthe count of call stacks into that functionfor the original profile.profilerFor a comparison flame graph, the focus list also includestwo columns labeledDiff, a button labeledRelative Diff, and abutton labeledAbsolute Diff. For information on the relative differenceand absolute difference, seeDisplayed metric values.

By default, the color of the comparison flame graph is determined by the absolutedifferences between the original and compared profiles. In contrast, by default,the focus list displays the relative differences between the two profilesbeing compared:

Focus list showing relative difference between two profiles.

The table in the example shows that the functionfoo1 takes about4.67 seconds to run in the original profile. The time 4.67 seconds correspondsto about 46.6% of the runtime. TheDiff column, which displays therelative difference, contains the value of-22.4%.

To view the absolute difference between metric values, clickAbsolute Diff.

Whether you have a standard flame graph or a comparison flame graph,you can sort the table rows in ascending ordescendingorder by selecting a table header element.

Turning off comparison mode

To turn off comparison mode, set theCompare to field toNone.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.