Skip to content

Instantly share code, notes, and snippets.

@virtuosonic
Created June 13, 2018 01:17
Show Gist options
  • Save virtuosonic/6d3c4d6bd7e43ba97173e90c5e7bfe47 to your computer and use it in GitHub Desktop.
Save virtuosonic/6d3c4d6bd7e43ba97173e90c5e7bfe47 to your computer and use it in GitHub Desktop.
/**************************************
Nombre: parallel.cpp
Autor: Gabriel Espinoza
Fecha: 12-Jun-2018
License: MIT
Desc: hace una comparacion del algoritmo sort
estandar y su version paralela
**************************************/
#include <vector>
#include <parallel/algorithm>
#include <algorithm>
#include <chrono>
#include <iostream>
using namespace std::chrono;
using namespace std;
int main()
{
std::vector<int> vector1(1e7);
auto start_t = steady_clock::now();
std::sort(vector1.begin(), vector1.end());
auto end_t = steady_clock::now();
cout << "std::sort " <<duration_cast<milliseconds>(end_t - start_t).count() << " milliseconds\n";
start_t = steady_clock::now();
__gnu_parallel::sort(vector1.begin(), vector1.end());
end_t = steady_clock::now();
cout << "__gnu_parallel::sort " <<duration_cast<milliseconds>(end_t - start_t).count() << " milliseconds\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment