> For the complete documentation index, see [llms.txt](https://jen-hsuan-hsieh.gitbook.io/debugging-tools-experience/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jen-hsuan-hsieh.gitbook.io/debugging-tools-experience/chapter5-xiao-neng-fen-xi/62c++/621smart-bear-aq-time.md).

# 6.3.1.SMART BEAR AQ Time

## 1.Introduction

* AQtime is a performance profiler and memory/resource debugging toolset developed by SmartBear Software. It is integrated into Microsoft Visual Studio, Visual Studio Test Projects and Embarcadero RAD Studio\[4] that allows analyzing the application without leaving the development environment (source: [wiki](https://en.wikipedia.org/wiki/AQtime))

## 2.Profiling

* 1.Install AQ Time Software
* 2.Create a AQ Time Project
  * Right click on solution and select **Add -> New Project**

    ![](https://github.com/jenhsuan/debugging-tools-experience/tree/91ad7a157f155ea77065c5600800bb4627bd1ae2/assets/螢幕快照%202017-09-10%20下午5.01.33.png)
* 3.Set profiling target output file
  * On Setup page of AQ Time Project, right click on left side bar and select **Add Output**

    ![](https://github.com/jenhsuan/debugging-tools-experience/tree/91ad7a157f155ea77065c5600800bb4627bd1ae2/assets/螢幕快照%202017-09-10%20下午5.01.57.png)
* 4.Start profiling
  * Select AQtime->Run from menu bar, then the target output file you set before will be launched, do the action what you want to profile

    ![](https://github.com/jenhsuan/debugging-tools-experience/tree/91ad7a157f155ea77065c5600800bb4627bd1ae2/assets/螢幕快照%202017-09-10%20下午5.02.29.png)
* 5.Get result
  * 1.Click **Get results** you can get a report from start to present
    * Time
    * Time with Children
    * Hot Count

      ![](https://github.com/jenhsuan/debugging-tools-experience/tree/91ad7a157f155ea77065c5600800bb4627bd1ae2/assets/螢幕快照%202017-09-10%20下午5.04.26.png)
  * 2.Click one function that you would like to know the detail, you can click **Panel List -> Call Graph**

    ![](https://github.com/jenhsuan/debugging-tools-experience/tree/91ad7a157f155ea77065c5600800bb4627bd1ae2/assets/螢幕快照%202017-09-10%20下午5.05.46.png)

    ![](https://github.com/jenhsuan/debugging-tools-experience/tree/91ad7a157f155ea77065c5600800bb4627bd1ae2/assets/螢幕快照%202017-09-10%20下午5.06.32.png)
  * 3.Finally, you can get some information such as: Code Type, Hit Count, Time, Time with Children for selected function and children function

    ![](https://github.com/jenhsuan/debugging-tools-experience/tree/91ad7a157f155ea77065c5600800bb4627bd1ae2/assets/螢幕快照%202017-09-10%20下午5.07.24.png)

## 3.Filtering less relevant functions

* In order to find out the performance bottleneck, we can exclude some sections or functions if they are not part of your

## 4.Optimize performance

* 1.Found the performance bottleneck from report and graph which AQ time generated
* 2.For example, I find that DoNavigationLineOverlapCheck() was the performance bottleneck, check it's children by checking graph&#x20;

  ![](https://github.com/jenhsuan/debugging-tools-experience/tree/91ad7a157f155ea77065c5600800bb4627bd1ae2/assets/螢幕快照%202017-09-10%20下午5.09.19.png)
* 3.The constructor of LaneLineInfo will be called many time because we create new LaneLineInfo Objects in for loop &#x20;

```
LanelineList NavigationSplineOverlapCheck::CheckAndGetFailedLines(
    const LanelineList& aLanelineList,
    int* aTotalCheck /*= nullptr*/)
{
    static const double aNavigationLineWidth = FileData::GetConfigReader()->GetNavigationLineWidth();

    LanelineList failedLineList;
    if (aTotalCheck != nullptr)
    {
        *aTotalCheck = 0;
    }
    bool checkFlag = false;
    int laneLineSize = aLanelineList.size();
    for(int i = 0 ; i < laneLineSize; i++)
    {
        checkFlag = false;
        LanelineInfo outerLane = aLanelineList[i];
        for(int j = i + 1 ; j < laneLineSize; j++)
        {
            LanelineInfo innerLane = aLanelineList[j];
            if( innerLane._fromLane._line2DId == outerLane._fromLane._line2DId &&
                innerLane._toLane._line2DId == outerLane._toLane._line2DId)
            {
                ...
```

* 4.To optimize the performance of this function and also maintain readability, using const reference was a good choice in this case&#x20;

```
LanelineList NavigationSplineOverlapCheck::CheckAndGetFailedLines(
    const LanelineList& aLanelineList,
    int* aTotalCheck /*= nullptr*/)
{
    static const double aNavigationLineWidth = FileData::GetConfigReader()->GetNavigationLineWidth();

    LanelineList failedLineList;
    if (aTotalCheck != nullptr)
    {
        *aTotalCheck = 0;
    }
    bool checkFlag = false;
    int laneLineSize = aLanelineList.size();
    for(int i = 0 ; i < laneLineSize; i++)
    {
        checkFlag = false;
        const LanelineInfo& outerLane = aLanelineList[i];
        for(int j = i + 1 ; j < laneLineSize; j++)
        {
            const LanelineInfo& innerLane = aLanelineList[j];
            if( innerLane._fromLane._line2DId == outerLane._fromLane._line2DId &&
                innerLane._toLane._line2DId == outerLane._toLane._line2DId)
            {
                ...
```

* 5.Check the graph again after we modify the code, the change optimize the performance for sure according to the latest time cost of LaneLineInfo is smaller than before

  ![](https://github.com/jenhsuan/debugging-tools-experience/tree/91ad7a157f155ea77065c5600800bb4627bd1ae2/assets/螢幕快照%202017-09-10%20下午5.10.45.png)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jen-hsuan-hsieh.gitbook.io/debugging-tools-experience/chapter5-xiao-neng-fen-xi/62c++/621smart-bear-aq-time.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
