草庐IT

toBigEndian

全部标签

c++ - 函数指针比内联函数运行得更快。为什么?

我在我的计算机(Inteli3-3220@3.3GHz,Fedora18)上运行了一个基准测试,得到了意想不到的结果。函数指针实际上比内联函数快一点。代码:#include#includeinlineshorttoBigEndian(shorti){return(i>8);}short(*toBigEndianPtr)(shorti)=toBigEndian;intmain(){std::chrono::durationt;inttotal=0;for(inti=0;i>(end-begin);}std::cout编译为g++test.cpp-std=c++0x-O0“toBigEnd