| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/concurrent/qtconcurrentiteratekernel.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | - | |||||||
| 8 | - | |||||||
| 9 | - | |||||||
| 10 | - | |||||||
| 11 | enum { | - | ||||||
| 12 | TargetRatio = 100, | - | ||||||
| 13 | MedianSize = 7 | - | ||||||
| 14 | }; | - | ||||||
| 15 | static qint64 getticks() | - | ||||||
| 16 | { | - | ||||||
| 17 | - | |||||||
| 18 | clockid_t clockId; | - | ||||||
| 19 | - | |||||||
| 20 | - | |||||||
| 21 | - | |||||||
| 22 | - | |||||||
| 23 | - | |||||||
| 24 | clockId = 0; | - | ||||||
| 25 | - | |||||||
| 26 | - | |||||||
| 27 | - | |||||||
| 28 | static QBasicAtomicInt sUseThreadCpuTime = { -2 }; | - | ||||||
| 29 | int useThreadCpuTime = sUseThreadCpuTime.load(); | - | ||||||
| 30 |     if (useThreadCpuTime == -2
  | 4-37244 | ||||||
| 31 | - | |||||||
| 32 | - | |||||||
| 33 |         useThreadCpuTime = sysconf(_SC_THREAD_CPUTIME) == -1L
  | 0-4 | ||||||
| 34 | sUseThreadCpuTime.store(useThreadCpuTime); | - | ||||||
| 35 |     } executed 4 times by 4 tests:  end of blockExecuted by: 
  | 4 | ||||||
| 36 |     if (useThreadCpuTime != -1
  | 0-37248 | ||||||
| 37 |         clockId = 3; executed 37248 times by 4 tests:  clockId = 3;Executed by: 
  | 37248 | ||||||
| 38 | - | |||||||
| 39 | - | |||||||
| 40 | - | |||||||
| 41 | - | |||||||
| 42 | - | |||||||
| 43 | struct timespec ts; | - | ||||||
| 44 |     if (clock_gettime(clockId, &ts) == -1
  | 0-37248 | ||||||
| 45 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||
| 46 |     return executed 37248 times by 4 tests:   (ts.tv_sec * 1000000000) + ts.tv_nsec;return (ts.tv_sec * 1000000000) + ts.tv_nsec;Executed by: 
 executed 37248 times by 4 tests:  return (ts.tv_sec * 1000000000) + ts.tv_nsec;Executed by: 
  | 37248 | ||||||
| 47 | - | |||||||
| 48 | - | |||||||
| 49 | - | |||||||
| 50 | - | |||||||
| 51 | - | |||||||
| 52 | - | |||||||
| 53 | - | |||||||
| 54 | } | - | ||||||
| 55 | static double elapsed(qint64 after, qint64 before) | - | ||||||
| 56 | { | - | ||||||
| 57 |     return executed 37248 times by 4 tests:   double(after - before);return double(after - before);Executed by: 
 executed 37248 times by 4 tests:  return double(after - before);Executed by: 
  | 37248 | ||||||
| 58 | } | - | ||||||
| 59 | - | |||||||
| 60 | namespace QtConcurrent { | - | ||||||
| 61 | - | |||||||
| 62 | - | |||||||
| 63 | - | |||||||
| 64 | - | |||||||
| 65 | BlockSizeManager::BlockSizeManager(int iterationCount) | - | ||||||
| 66 | : maxBlockSize(iterationCount / (QThreadPool::globalInstance()->maxThreadCount() * 2)), | - | ||||||
| 67 | beforeUser(0), afterUser(0), | - | ||||||
| 68 | controlPartElapsed(MedianSize), userPartElapsed(MedianSize), | - | ||||||
| 69 | m_blockSize(1) | - | ||||||
| 70 | { } never executed:  end of block | 0 | ||||||
| 71 | - | |||||||
| 72 | - | |||||||
| 73 | void BlockSizeManager::timeBeforeUser() | - | ||||||
| 74 | { | - | ||||||
| 75 |     if (blockSizeMaxed()
  | 0 | ||||||
| 76 |         return; never executed:  return; | 0 | ||||||
| 77 | - | |||||||
| 78 | beforeUser = getticks(); | - | ||||||
| 79 | controlPartElapsed.addValue(elapsed(beforeUser, afterUser)); | - | ||||||
| 80 | } never executed:  end of block | 0 | ||||||
| 81 | - | |||||||
| 82 | - | |||||||
| 83 | - | |||||||
| 84 | void BlockSizeManager::timeAfterUser() | - | ||||||
| 85 | { | - | ||||||
| 86 |     if (blockSizeMaxed()
  | 0 | ||||||
| 87 |         return; never executed:  return; | 0 | ||||||
| 88 | - | |||||||
| 89 | afterUser = getticks(); | - | ||||||
| 90 | userPartElapsed.addValue(elapsed(afterUser, beforeUser)); | - | ||||||
| 91 | - | |||||||
| 92 |     if (controlPartElapsed.isMedianValid() == false
  | 0 | ||||||
| 93 |         return; never executed:  return; | 0 | ||||||
| 94 | - | |||||||
| 95 |     if (controlPartElapsed.median() * TargetRatio < userPartElapsed.median()
  | 0 | ||||||
| 96 |         return; never executed:  return; | 0 | ||||||
| 97 | - | |||||||
| 98 | m_blockSize = qMin(m_blockSize * 2, maxBlockSize); | - | ||||||
| 99 | - | |||||||
| 100 | - | |||||||
| 101 | - | |||||||
| 102 | - | |||||||
| 103 | - | |||||||
| 104 | - | |||||||
| 105 | - | |||||||
| 106 | controlPartElapsed.reset(); | - | ||||||
| 107 | userPartElapsed.reset(); | - | ||||||
| 108 | } never executed:  end of block | 0 | ||||||
| 109 | - | |||||||
| 110 | int BlockSizeManager::blockSize() | - | ||||||
| 111 | { | - | ||||||
| 112 |     return never executed:   m_blockSize;return m_blockSize;never executed:  return m_blockSize; | 0 | ||||||
| 113 | } | - | ||||||
| 114 | - | |||||||
| 115 | - | |||||||
| 116 | - | |||||||
| 117 | - | |||||||
| 118 | BlockSizeManagerV2::BlockSizeManagerV2(int iterationCount) | - | ||||||
| 119 | : maxBlockSize(iterationCount / (QThreadPool::globalInstance()->maxThreadCount() * 2)), | - | ||||||
| 120 | beforeUser(0), afterUser(0), | - | ||||||
| 121 | m_blockSize(1) | - | ||||||
| 122 | { } executed 20974 times by 4 tests:  end of blockExecuted by: 
  | 20974 | ||||||
| 123 | - | |||||||
| 124 | - | |||||||
| 125 | void BlockSizeManagerV2::timeBeforeUser() | - | ||||||
| 126 | { | - | ||||||
| 127 |     if (blockSizeMaxed()
  | 560-18624 | ||||||
| 128 |         return; executed 560 times by 2 tests:  return;Executed by: 
  | 560 | ||||||
| 129 | - | |||||||
| 130 | beforeUser = getticks(); | - | ||||||
| 131 | controlPartElapsed.addValue(elapsed(beforeUser, afterUser)); | - | ||||||
| 132 | } executed 18624 times by 4 tests:  end of blockExecuted by: 
  | 18624 | ||||||
| 133 | - | |||||||
| 134 | - | |||||||
| 135 | - | |||||||
| 136 | void BlockSizeManagerV2::timeAfterUser() | - | ||||||
| 137 | { | - | ||||||
| 138 |     if (blockSizeMaxed()
  | 559-18624 | ||||||
| 139 |         return; executed 559 times by 2 tests:  return;Executed by: 
  | 559 | ||||||
| 140 | - | |||||||
| 141 | afterUser = getticks(); | - | ||||||
| 142 | userPartElapsed.addValue(elapsed(afterUser, beforeUser)); | - | ||||||
| 143 | - | |||||||
| 144 |     if (controlPartElapsed.isMedianValid() == false
  | 2534-16090 | ||||||
| 145 |         return; executed 16090 times by 4 tests:  return;Executed by: 
  | 16090 | ||||||
| 146 | - | |||||||
| 147 |     if (controlPartElapsed.median() * TargetRatio < userPartElapsed.median()
  | 0-2534 | ||||||
| 148 |         return; never executed:  return; | 0 | ||||||
| 149 | - | |||||||
| 150 | m_blockSize = qMin(m_blockSize * 2, maxBlockSize); | - | ||||||
| 151 | - | |||||||
| 152 | - | |||||||
| 153 | - | |||||||
| 154 | - | |||||||
| 155 | - | |||||||
| 156 | - | |||||||
| 157 | - | |||||||
| 158 | controlPartElapsed.reset(); | - | ||||||
| 159 | userPartElapsed.reset(); | - | ||||||
| 160 | } executed 2534 times by 4 tests:  end of blockExecuted by: 
  | 2534 | ||||||
| 161 | - | |||||||
| 162 | int BlockSizeManagerV2::blockSize() | - | ||||||
| 163 | { | - | ||||||
| 164 |     return executed 40062 times by 4 tests:   m_blockSize;return m_blockSize;Executed by: 
 executed 40062 times by 4 tests:  return m_blockSize;Executed by: 
  | 40062 | ||||||
| 165 | } | - | ||||||
| 166 | - | |||||||
| 167 | } | - | ||||||
| 168 | - | |||||||
| 169 | - | |||||||
| Switch to Source code | Preprocessed file |