Mercurial > hg > svcore
comparison base/test/StressEventSeries.h @ 1631:b2048f350906 single-point
Switch EventSeries to using a vector for m_events, so as to allow indexed access
author | Chris Cannam |
---|---|
date | Tue, 12 Mar 2019 14:14:00 +0000 |
parents | 6db21df9f376 |
children | c077a97d055f |
comparison
equal
deleted
inserted
replaced
1630:73bda079567a | 1631:b2048f350906 |
---|---|
37 << "ms" << endl; | 37 << "ms" << endl; |
38 } | 38 } |
39 | 39 |
40 void short_n(int n) { | 40 void short_n(int n) { |
41 clock_t start = clock(); | 41 clock_t start = clock(); |
42 std::set<Event> ee; | |
42 EventSeries s; | 43 EventSeries s; |
43 for (int i = 0; i < n; ++i) { | 44 for (int i = 0; i < n; ++i) { |
44 float value = float(rand()) / float(RAND_MAX); | 45 float value = float(rand()) / float(RAND_MAX); |
45 Event e(rand(), value, 1000, QString("event %1").arg(i)); | 46 Event e(rand(), value, 1000, QString("event %1").arg(i)); |
47 ee.insert(e); | |
48 } | |
49 for (const Event &e: ee) { | |
46 s.add(e); | 50 s.add(e); |
47 } | 51 } |
48 QCOMPARE(s.count(), n); | 52 QCOMPARE(s.count(), n); |
49 clock_t end = clock(); | 53 clock_t end = clock(); |
50 report(n, "short", start, end); | 54 report(n, "short", start, end); |
51 } | 55 } |
52 | 56 |
53 void longish_n(int n) { | 57 void longish_n(int n) { |
54 clock_t start = clock(); | 58 clock_t start = clock(); |
59 std::set<Event> ee; | |
55 EventSeries s; | 60 EventSeries s; |
56 for (int i = 0; i < n; ++i) { | 61 for (int i = 0; i < n; ++i) { |
57 float value = float(rand()) / float(RAND_MAX); | 62 float value = float(rand()) / float(RAND_MAX); |
58 Event e(rand(), value, rand() / 1000, QString("event %1").arg(i)); | 63 Event e(rand(), value, rand() / 1000, QString("event %1").arg(i)); |
64 ee.insert(e); | |
65 } | |
66 for (const Event &e: ee) { | |
59 s.add(e); | 67 s.add(e); |
60 } | 68 } |
61 QCOMPARE(s.count(), n); | 69 QCOMPARE(s.count(), n); |
62 clock_t end = clock(); | 70 clock_t end = clock(); |
63 report(n, "longish", start, end); | 71 report(n, "longish", start, end); |
69 void short_5() { short_n(100000); } | 77 void short_5() { short_n(100000); } |
70 void short_6() { short_n(1000000); } | 78 void short_6() { short_n(1000000); } |
71 void longish_3() { longish_n(1000); } | 79 void longish_3() { longish_n(1000); } |
72 void longish_4() { longish_n(10000); } | 80 void longish_4() { longish_n(10000); } |
73 void longish_5() { longish_n(100000); } | 81 void longish_5() { longish_n(100000); } |
74 | |
75 /* | |
76 | |
77 (T540p, Core i5-4330M @ 2.80GHz, 16G) | |
78 | |
79 cf5196881e3e: | |
80 | |
81 Time for 1000 short events = 1.169ms | |
82 Time for 10000 short events = 20.566ms | |
83 Time for 100000 short events = 279.242ms | |
84 Time for 1000000 short events = 3925.06ms | |
85 Time for 1000 longish events = 1.938ms | |
86 Time for 10000 longish events = 72.209ms | |
87 Time for 100000 longish events = 6469.26ms | |
88 | |
89 Totals: 9 passed, 0 failed, 0 skipped, 0 blacklisted, 12785ms | |
90 | |
91 13.40user 0.37system 0:13.84elapsed 99%CPU (0avgtext+0avgdata 1052000maxresident)k | |
92 0inputs+40outputs (0major+260249minor)pagefaults 0swaps | |
93 | |
94 | |
95 dcd510bd89db: | |
96 | |
97 Time for 1000 short events = 1.824ms | |
98 Time for 10000 short events = 19.203ms | |
99 Time for 100000 short events = 270.631ms | |
100 Time for 1000000 short events = 4425.2ms | |
101 Time for 1000 longish events = 2.395ms | |
102 Time for 10000 longish events = 83.623ms | |
103 Time for 100000 longish events = 5958.28ms | |
104 | |
105 Totals: 9 passed, 0 failed, 0 skipped, 0 blacklisted, 13116ms | |
106 | |
107 13.64user 0.26system 0:13.98elapsed 99%CPU (0avgtext+0avgdata 948104maxresident)k | |
108 0inputs+40outputs (0major+234387minor)pagefaults 0swaps | |
109 | |
110 895186c43fce: | |
111 | |
112 Time for 1000 short events = 1.706ms | |
113 Time for 10000 short events = 23.192ms | |
114 Time for 100000 short events = 310.605ms | |
115 Time for 1000000 short events = 4675.7ms | |
116 Time for 1000 longish events = 2.186ms | |
117 Time for 10000 longish events = 760.659ms | |
118 Time for 100000 longish events = 1335.57ms | |
119 | |
120 Totals: 9 passed, 0 failed, 0 skipped, 0 blacklisted, 7804ms | |
121 | |
122 7.97user 0.29system 0:08.31elapsed 99%CPU (0avgtext+0avgdata 706388maxresident)k | |
123 0inputs+40outputs (0major+182225minor)pagefaults 0swaps | |
124 | |
125 1c21ddac220e (with simpler code): | |
126 | |
127 Time for 1000 short events = 1.12ms | |
128 Time for 10000 short events = 14.997ms | |
129 Time for 100000 short events = 238.818ms | |
130 Time for 1000000 short events = 3765.09ms | |
131 Time for 1000 longish events = 1.657ms | |
132 Time for 10000 longish events = 1130.59ms | |
133 Time for 100000 longish events = 1840.98ms | |
134 | |
135 Totals: 9 passed, 0 failed, 0 skipped, 0 blacklisted, 8081ms | |
136 | |
137 7.88user 0.23system 0:08.19elapsed 99%CPU (0avgtext+0avgdata 781688maxresident)k | |
138 0inputs+40outputs (0major+200425minor)pagefaults 0swaps | |
139 | |
140 */ | |
141 }; | 82 }; |
142 | 83 |
143 #endif | 84 #endif |