Visual studio cpu评测时没有数据-visual studio

Visual studio cpu评测时没有数据-visual studio,visual-studio,profiling,cpu,Visual Studio,Profiling,Cpu,我试图分析代码的性能,这就是我得到的: 我从microsoft文档中获取了关于评测的主题代码: #include <iostream> #include <limits> #include <mutex> #include <random> #include <functional> //.cpp file code: static constexpr int MIN_ITERATIONS = std::numeric_limit

我试图分析代码的性能,这就是我得到的:

我从microsoft文档中获取了关于评测的主题代码:

#include <iostream>
#include <limits>
#include <mutex>
#include <random>
#include <functional>

//.cpp file code:

static constexpr int MIN_ITERATIONS = std::numeric_limits<int>::max() / 1000;
static constexpr int MAX_ITERATIONS = MIN_ITERATIONS + 10000;

long long m_totalIterations = 0;
std::mutex m_totalItersLock;

int getNumber()
{

    std::uniform_int_distribution<int> num_distribution(MIN_ITERATIONS, MAX_ITERATIONS);
    std::mt19937 random_number_engine; // pseudorandom number generator
    auto get_num = std::bind(num_distribution, random_number_engine);
    int random_num = get_num();

    auto result = 0;
    {
        std::lock_guard<std::mutex> lock(m_totalItersLock);
        m_totalIterations += random_num;
    }
    // we're just spinning here
    // to increase CPU usage
    for (int i = 0; i < random_num; i++)
    {
        result = get_num();
    }
    return result;
}

void doWork()
{
    std::wcout << L"The doWork function is running on another thread." << std::endl;

    auto x = getNumber();
}

int main()
{
    std::vector<std::thread> threads;

    for (int i = 0; i < 10; ++i) {

        threads.push_back(std::thread(doWork));
        std::cout << "The Main() thread calls this after starting the new thread" << std::endl;
    }

    for (auto& thread : threads) {
        thread.join();
    }

    return 0;
}
#包括
#包括
#包括
#包括
#包括
//.cpp文件代码:
静态constexpr int MIN_ITERATIONS=std::numeric_limits::max()/1000;
静态constexpr int MAX_迭代次数=MIN_迭代次数+10000;
长m_总迭代次数=0;
std::mutex m_totalItersLock;
int getNumber()
{
std::均匀分布数分布(最小迭代,最大迭代);
std::mt19937随机数引擎;//伪随机数生成器
自动获取num=std::bind(num分布,随机数引擎);
int random_num=get_num();
自动结果=0;
{
标准:锁和防护锁(m_totalItersLock);
m_totalIterations+=随机数;
}
//我们只是在这里旋转
//提高CPU使用率
for(int i=0;i