小编rbt*_*rht的帖子

perf record(或其他分析器)如何选择将哪条指令算作消耗时间?

最近,我发现实际上 perf (或 pprof)可能会在反汇编视图指令时序中显示在实际上没有花费这个时间的行附近。真正的指令,实际上花了这个时间,就在它之前。我知道一个模糊的解释,这是由于 CPU 中的指令流水线造成的。不过,我想了解以下内容:

  1. 对于这个效果有更详细的解释吗?
  2. 它记录在 perf 或 pprof 中吗?我还没有找到任何参考资料。
  3. 有没有办法获得正确放置的时间?

performance assembly cpu-architecture perf

5
推荐指数
1
解决办法
808
查看次数

int &&使用int和参数初始化函数

我有以下代码:

#include <type_traits>

struct TType
{
    int a = 0;

    bool operator() (int&)
    {
        return true;
    }
};

int main()
{
    static_assert(std::is_same<decltype(std::declval<TType>()(std::declval<int>())), bool>::value, "wtf?");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

如果我尝试用g ++ - 4.8.2编译它,那么我收到一个错误:

main.cpp:321:82: error: no match for call to ‘(JetPlane) (int)’
static_assert(std::is_same<decltype(std::declval<JetPlane>()(std::declval<int>())), bool>::value, "wtf?");
                                                                                ^
main.cpp:265:8: note: candidate is:
struct JetPlane
       ^
main.cpp:279:7: note: bool JetPlane::operator()(int&)
bool operator() (int&)
     ^
main.cpp:279:7: note:   no known conversion for argument 1 from ‘int’ to ‘int&’
Run Code Online (Sandbox Code Playgroud)

我不明白note: no known conversion for argument 1 from …

c++ c++11

3
推荐指数
1
解决办法
1113
查看次数

标签 统计

assembly ×1

c++ ×1

c++11 ×1

cpu-architecture ×1

perf ×1

performance ×1