perf_stl_sort.cpp 946 B

123456789101112131415161718192021222324252627282930313233
  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 <algorithm>
  11. #include <iostream>
  12. #include "perf.hpp"
  13. int main(int argc, char *argv[])
  14. {
  15. perf_parse_args(argc, argv);
  16. std::cout << "size: " << PERF_N << std::endl;
  17. std::vector<int> v;
  18. perf_timer t;
  19. for(size_t trial = 0; trial < PERF_TRIALS; trial++){
  20. v = generate_random_vector<int>(PERF_N);
  21. t.start();
  22. std::sort(v.begin(), v.end());
  23. t.stop();
  24. }
  25. std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
  26. return 0;
  27. }