perf_tbb_sort.cpp 992 B

1234567891011121314151617181920212223242526272829303132333435
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #include <iostream>
  11. #include <vector>
  12. #include <tbb/parallel_sort.h>
  13. #include "perf.hpp"
  14. int main(int argc, char *argv[])
  15. {
  16. perf_parse_args(argc, argv);
  17. std::cout << "size: " << PERF_N << std::endl;
  18. std::vector<int> v(PERF_N);
  19. perf_timer t;
  20. for(size_t trial = 0; trial < PERF_TRIALS; trial++){
  21. v = generate_random_vector<int>(PERF_N);
  22. t.start();
  23. tbb::parallel_sort(v.begin(), v.end());
  24. t.stop();
  25. }
  26. std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
  27. return 0;
  28. }