为了优化和提高性能,我通过一个站点对c++中的小函数和小方法进行了基准测试,我发现了一些关于字符串的结果,我不知道为什么。基准测试代码的链接。
static void StringCreation(benchmark::State& state) {
// Code inside this loop is measured repeatedly
for (auto _ : state) {
std::string created_string("hello");
// Make sure the variable is not optimized