Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Strings are overkill for parmap_test.
[simgrid.git] / teshsuite / xbt / parmap_test / parmap_test.cpp
index 30da8b5..ce3082c 100644 (file)
@@ -1,6 +1,6 @@
 /* parmap_test -- test parmap                                               */
 
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -13,7 +13,6 @@
 #include <algorithm>
 #include <cstdlib>
 #include <numeric> // std::iota
-#include <sstream>
 #include <thread>
 #include <vector>
 
@@ -52,11 +51,9 @@ static int test_parmap_basic(e_xbt_parmap_mode_t mode)
   return ret;
 }
 
-static void fun_get_id(std::string* arg)
+static void fun_get_id(std::thread::id* arg)
 {
-  std::stringstream ss;
-  ss << std::this_thread::get_id();
-  *arg = ss.str();
+  *arg = std::this_thread::get_id();
   xbt_os_sleep(0.05);
 }
 
@@ -67,15 +64,15 @@ static int test_parmap_extended(e_xbt_parmap_mode_t mode)
   for (unsigned num_workers = 1; num_workers <= 16; num_workers *= 2) {
     const unsigned len = 2 * num_workers;
 
-    simgrid::xbt::Parmap<std::string*> parmap(num_workers, mode);
-    std::vector<std::string> a(len);
-    std::vector<std::string*> data(len);
+    simgrid::xbt::Parmap<std::thread::id*> parmap(num_workers, mode);
+    std::vector<std::thread::id> a(len);
+    std::vector<std::thread::id*> data(len);
     std::iota(begin(data), end(data), &a[0]);
 
     parmap.apply(fun_get_id, data);
 
     std::sort(begin(a), end(a));
-    unsigned count = std::distance(begin(a), std::unique(begin(a), end(a)));
+    unsigned count = static_cast<unsigned>(std::distance(begin(a), std::unique(begin(a), end(a))));
     if (count != num_workers) {
       XBT_CRITICAL("only %u/%u threads did some work", count, num_workers);
       ret = 1;