Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | enum { | - |
8 | TargetRatio = 100, | - |
9 | MedianSize = 7 | - |
10 | }; | - |
11 | static qint64 getticks() | - |
12 | { | - |
13 | | - |
14 | clockid_t clockId; | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | clockId = 0; | - |
21 | | - |
22 | | - |
23 | | - |
24 | static long useThreadCpuTime = -2; | - |
25 | if (useThreadCpuTime == -2) { evaluated: useThreadCpuTime == -2 yes Evaluation Count:9 | yes Evaluation Count:152591 |
| 9-152591 |
26 | | - |
27 | useThreadCpuTime = sysconf(_SC_THREAD_CPUTIME); | - |
28 | } executed: } Execution Count:5 | 5 |
29 | if (useThreadCpuTime != -1) partially evaluated: useThreadCpuTime != -1 yes Evaluation Count:153076 | no Evaluation Count:0 |
| 0-153076 |
30 | clockId = 3; executed: clockId = 3; Execution Count:153560 | 153560 |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | struct timespec ts; | - |
37 | if (clock_gettime(clockId, &ts) == -1) partially evaluated: clock_gettime(clockId, &ts) == -1 no Evaluation Count:0 | yes Evaluation Count:155608 |
| 0-155608 |
38 | return 0; never executed: return 0; | 0 |
39 | return (ts.tv_sec * 1000000000) + ts.tv_nsec; executed: return (ts.tv_sec * 1000000000) + ts.tv_nsec; Execution Count:154291 | 154291 |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | } | - |
48 | static double elapsed(qint64 after, qint64 before) | - |
49 | { | - |
50 | return double(after - before); executed: return double(after - before); Execution Count:155490 | 155490 |
51 | } | - |
52 | | - |
53 | namespace QtConcurrent { | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | BlockSizeManager::BlockSizeManager(int iterationCount) | - |
59 | : maxBlockSize(iterationCount / (QThreadPool::globalInstance()->maxThreadCount() * 2)), | - |
60 | beforeUser(0), afterUser(0), | - |
61 | controlPartElapsed(MedianSize), userPartElapsed(MedianSize), | - |
62 | m_blockSize(1) | - |
63 | { } executed: } Execution Count:25869 | 25869 |
64 | | - |
65 | | - |
66 | void BlockSizeManager::timeBeforeUser() | - |
67 | { | - |
68 | if (blockSizeMaxed()) evaluated: blockSizeMaxed() yes Evaluation Count:1013 | yes Evaluation Count:78518 |
| 1013-78518 |
69 | return; executed: return; Execution Count:1013 | 1013 |
70 | | - |
71 | beforeUser = getticks(); | - |
72 | controlPartElapsed.addValue(elapsed(beforeUser, afterUser)); | - |
73 | } executed: } Execution Count:79027 | 79027 |
74 | | - |
75 | | - |
76 | | - |
77 | void BlockSizeManager::timeAfterUser() | - |
78 | { | - |
79 | if (blockSizeMaxed()) evaluated: blockSizeMaxed() yes Evaluation Count:1013 | yes Evaluation Count:78767 |
| 1013-78767 |
80 | return; executed: return; Execution Count:1013 | 1013 |
81 | | - |
82 | afterUser = getticks(); | - |
83 | userPartElapsed.addValue(elapsed(afterUser, beforeUser)); | - |
84 | | - |
85 | if (controlPartElapsed.isMedianValid() == false) evaluated: controlPartElapsed.isMedianValid() == false yes Evaluation Count:68580 | yes Evaluation Count:10218 |
| 10218-68580 |
86 | return; executed: return; Execution Count:68474 | 68474 |
87 | | - |
88 | if (controlPartElapsed.median() * TargetRatio < userPartElapsed.median()) partially evaluated: controlPartElapsed.median() * TargetRatio < userPartElapsed.median() no Evaluation Count:0 | yes Evaluation Count:10188 |
| 0-10188 |
89 | return; | 0 |
90 | | - |
91 | m_blockSize = qMin(m_blockSize * 2, maxBlockSize); | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | controlPartElapsed.reset(); | - |
100 | userPartElapsed.reset(); | - |
101 | } executed: } Execution Count:10200 | 10200 |
102 | | - |
103 | int BlockSizeManager::blockSize() | - |
104 | { | - |
105 | return m_blockSize; executed: return m_blockSize; Execution Count:104102 | 104102 |
106 | } | - |
107 | | - |
108 | } | - |
109 | | - |
110 | | - |
111 | | - |
| | |