[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/HibsStatement/taskflow/master/examples/parallel_sort.cpp [Back]  [Original]

// This program demonstrates how to sort a vector of strings
// in parallel using tf::Taskflow::sort and compares it against
// the sequential sort std::sort.
#include 
#include 

// generate a random string
std::string random_string(size_t len) {

  std::string tmp_s;
  static const char alphanum[] =
    "0123456789"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "abcdefghijklmnopqrstuvwxyz";

  std::default_random_engine eng{std::random_device{}()};
  std::uniform_int_distribution dist(1, 100000);

  tmp_s.reserve(len);

  for (size_t i = 0; i < len; ++i) {
    tmp_s += alphanum[dist(eng) % (sizeof(alphanum) - 1)];
  }

  return tmp_s;
}

// generate a vector of random strings
std::vector random_strings() {
  std::vector strings(1000000);
  std::cout 

Web Proxy Viewer  |  New URL  |  Original Page