static void BM_MSVC_concurrent_vector(benchmark::State &state)
{
    Concurrency::concurrent_vector<double> vec;

    for (auto _ : state)
    {
        vec.push_back(3.1415926);
        vec.push_back(2.71828);
        vec.push_back(3.1415926);
        vec.push_back(42);
        vec.push_back(0);
    }
}
Exemplo n.º 2
0
Counts count(const std::vector<std::wstring>& files)
{
    Counts map;

    Concurrency::concurrent_vector<int> vec;

    Concurrency::parallel_for_each(files.begin(), files.end(), [&vec](std::wstring file) {
        std::ifstream input(file);
        std::string line;
        while (std::getline(input, line)!=0) {
            if (line.size()>6 && boost::starts_with(line, "DYEAR=")) {
                try {
                    int year = boost::lexical_cast<int>(line.substr(6));
                    vec.push_back(year);
                    break;
                }
                catch (boost::bad_lexical_cast&)
                {}
            }
        }
    });

    std::for_each(vec.begin(), vec.end(), [&map](int i) {
        map[i]++;
    });

    return map;
}