Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1.  
  2. class ThreadChunk : public FRunnable {
  3. public:
  4.     bool bAlive = true;
  5.     std::chrono::milliseconds msGen;
  6.     std::vector<int> v;
  7.  
  8.     ThreadChunk()
  9.     {
  10.     }
  11.  
  12.     uint32 Run()
  13.     {
  14.         while (bAlive) {
  15.             auto t2 = Clock::now();
  16.  
  17.             v = std::vector<int>();
  18.             for (int i = 0; i < 99999999; i++) {
  19.                 v.push_back(rand());
  20.             }
  21.  
  22.             v = std::vector<int>();
  23.             for (int i = 0; i < 99999999; i++) {
  24.                 v.push_back(rand());
  25.             }
  26.            
  27.             auto t3 = Clock::now();
  28.  
  29.             msGen = std::chrono::duration_cast<std::chrono::milliseconds>(t3 - t2);
  30.  
  31.             std::this_thread::yield();
  32.         }
  33.         return 0;
  34.     }
  35.  
  36.     void Stop() {
  37.         bAlive = false;
  38.     }
  39.  
  40.     std::chrono::milliseconds GetTimeGen() {
  41.         return msGen;
  42.     }
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement