127
143
QString dbg = "created set: ";
128
144
for(std::set<Index>::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it)
129
145
dbg += QString("%1 ").arg(*it);
132
148
dbg = "repo. set: ";
133
149
for(std::set<Index>::const_iterator it = tempSet.begin(); it != tempSet.end(); ++it)
134
150
dbg += QString("%1 ").arg(*it);
137
kDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
153
qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
154
QFAIL("sets are not the same!");
139
QVERIFY(tempSet == realSets[a]);
142
158
for(int cycle = 0; cycle < 100; ++cycle) {
143
159
if(cycle % 10 == 0)
144
kDebug() << "cycle" << cycle;
160
qDebug() << "cycle" << cycle;
146
162
for(unsigned int a = 0; a < setCount; a++) {
147
163
for(unsigned int b = 0; b < setCount; b++) {
148
164
/// ----- SUBTRACTION/DIFFERENCE
149
165
std::set<Index> _realDifference;
151
std::set_difference(realSets[a].begin(), realSets[a].end(), realSets[b].begin(), realSets[b].end(), std::insert_iterator<std::set<Index> >(_realDifference, _realDifference.begin()));
152
genericDifferenceClockTime += clock() - c;
168
std::set_difference(realSets[a].begin(), realSets[a].end(), realSets[b].begin(), realSets[b].end(), std::insert_iterator<std::set<Index> >(_realDifference, _realDifference.begin()));
169
genericDifferenceTime += t.elapsed();
155
Set _difference = sets[a] - sets[b];
156
repositoryDifferenceClockTime += clock() - c;
175
_difference = sets[a] - sets[b];
176
repositoryDifferenceTime += t.elapsed();
158
179
if(_difference.stdSet() != _realDifference)
161
kDebug() << "SET a:";
182
qDebug() << "SET a:";
162
183
QString dbg = "";
163
184
for(std::set<Index>::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it)
164
185
dbg += QString("%1 ").arg(*it);
167
kDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
188
qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
170
kDebug() << "SET b:";
191
qDebug() << "SET b:";
171
192
QString dbg = "";
172
193
for(std::set<Index>::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it)
173
194
dbg += QString("%1 ").arg(*it);
176
kDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
197
qDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
180
201
std::set<Index> tempSet = _difference.stdSet();
182
kDebug() << "SET difference:";
203
qDebug() << "SET difference:";
183
204
QString dbg = "real set: ";
184
205
for(std::set<Index>::const_iterator it = _realDifference.begin(); it != _realDifference.end(); ++it)
185
206
dbg += QString("%1 ").arg(*it);
188
209
dbg = "repo. set: ";
189
210
for(std::set<Index>::const_iterator it = tempSet.begin(); it != tempSet.end(); ++it)
190
211
dbg += QString("%1 ").arg(*it);
193
kDebug() << "DOT-Graph:\n\n" << _difference.dumpDotGraph() << "\n\n";
214
qDebug() << "DOT-Graph:\n\n" << _difference.dumpDotGraph() << "\n\n";
216
QFAIL("difference sets are not the same!");
196
QVERIFY(_difference.stdSet() == _realDifference);
201
222
std::set<Index> _realUnion;
203
std::set_union(realSets[a].begin(), realSets[a].end(), realSets[b].begin(), realSets[b].end(), std::insert_iterator<std::set<Index> >(_realUnion, _realUnion.begin()));
204
genericUnionClockTime += clock() - c;
225
std::set_union(realSets[a].begin(), realSets[a].end(), realSets[b].begin(), realSets[b].end(), std::insert_iterator<std::set<Index> >(_realUnion, _realUnion.begin()));
226
genericUnionTime += t.elapsed();
207
Set _union = sets[a] + sets[b];
208
repositoryUnionClockTime += clock() - c;
232
_union = sets[a] + sets[b];
233
repositoryUnionTime += t.elapsed();
210
236
if(_union.stdSet() != _realUnion)
213
kDebug() << "SET a:";
239
qDebug() << "SET a:";
214
240
QString dbg = "";
215
241
for(std::set<Index>::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it)
216
242
dbg += QString("%1 ").arg(*it);
219
kDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
245
qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
222
kDebug() << "SET b:";
248
qDebug() << "SET b:";
223
249
QString dbg = "";
224
250
for(std::set<Index>::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it)
225
251
dbg += QString("%1 ").arg(*it);
228
kDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
254
qDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
232
258
std::set<Index> tempSet = _union.stdSet();
234
kDebug() << "SET union:";
260
qDebug() << "SET union:";
235
261
QString dbg = "real set: ";
236
262
for(std::set<Index>::const_iterator it = _realUnion.begin(); it != _realUnion.end(); ++it)
237
263
dbg += QString("%1 ").arg(*it);
240
266
dbg = "repo. set: ";
241
267
for(std::set<Index>::const_iterator it = tempSet.begin(); it != tempSet.end(); ++it)
242
268
dbg += QString("%1 ").arg(*it);
245
kDebug() << "DOT-Graph:\n\n" << _union.dumpDotGraph() << "\n\n";
271
qDebug() << "DOT-Graph:\n\n" << _union.dumpDotGraph() << "\n\n";
274
QFAIL("union sets are not the same");
248
QVERIFY(_union.stdSet() == _realUnion);
250
277
std::set<Index> _realIntersection;
252
279
/// -------- INTERSECTION
254
std::set_intersection(realSets[a].begin(), realSets[a].end(), realSets[b].begin(), realSets[b].end(), std::insert_iterator<std::set<Index> >(_realIntersection, _realIntersection.begin()));
255
genericIntersectionClockTime += clock() - c;
282
std::set_intersection(realSets[a].begin(), realSets[a].end(), realSets[b].begin(), realSets[b].end(), std::insert_iterator<std::set<Index> >(_realIntersection, _realIntersection.begin()));
283
genericIntersectionTime += t.elapsed();
257
286
//Just for fun: Test how fast QSet intersections are
258
287
QSet<Index> first, second;
259
for(std::set<Index>::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it)
288
for(std::set<Index>::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it) {
260
289
first.insert(*it);
261
for(std::set<Index>::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it)
291
for(std::set<Index>::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it) {
262
292
second.insert(*it);
264
QSet<Index> i = first.intersect(second);
265
qsetIntersectionClockTime += clock() - c;
268
Set _intersection = sets[a] & sets[b];
269
repositoryIntersectionClockTime += clock() - c;
296
QSet<Index> i = first.intersect(second);
297
qsetIntersectionTime += t.elapsed();
303
_intersection = sets[a] & sets[b];
304
repositoryIntersectionTime += t.elapsed();
272
307
if(_intersection.stdSet() != _realIntersection)
275
kDebug() << "SET a:";
310
qDebug() << "SET a:";
276
311
QString dbg = "";
277
312
for(std::set<Index>::const_iterator it = realSets[a].begin(); it != realSets[a].end(); ++it)
278
313
dbg += QString("%1 ").arg(*it);
281
kDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
316
qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
284
kDebug() << "SET b:";
319
qDebug() << "SET b:";
285
320
QString dbg = "";
286
321
for(std::set<Index>::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it)
287
322
dbg += QString("%1 ").arg(*it);
290
kDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
325
qDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
294
329
std::set<Index> tempSet = _intersection.stdSet();
296
kDebug() << "SET intersection:";
331
qDebug() << "SET intersection:";
297
332
QString dbg = "real set: ";
298
333
for(std::set<Index>::const_iterator it = _realIntersection.begin(); it != _realIntersection.end(); ++it)
299
334
dbg += QString("%1 ").arg(*it);
302
337
dbg = "repo. set: ";
303
338
for(std::set<Index>::const_iterator it = tempSet.begin(); it != tempSet.end(); ++it)
304
339
dbg += QString("%1 ").arg(*it);
307
kDebug() << "DOT-Graph:\n\n" << _intersection.dumpDotGraph() << "\n\n";
342
qDebug() << "DOT-Graph:\n\n" << _intersection.dumpDotGraph() << "\n\n";
344
QFAIL("intersection sets are not the same");
310
QVERIFY(_intersection.stdSet() == _realIntersection);
313
#ifdef DEBUG_STRINGREPOSITORY
314
kDebug() << "cycle " << cycle;
315
kDebug() << "Clock-cycles needed for set-building: repository-set: " << repositoryClockTime << " generic-set: " << genericClockTime;
316
kDebug() << "Clock-cycles needed for intersection: repository-sets: " << repositoryIntersectionClockTime << " generic-set: " << genericIntersectionClockTime << " QSet: " << qsetIntersectionClockTime;
317
kDebug() << "Clock-cycles needed for union: repository-sets: " << repositoryUnionClockTime << " generic-set: " << genericUnionClockTime;
318
kDebug() << "Clock-cycles needed for difference: repository-sets: " << repositoryDifferenceClockTime << " generic-set: " << genericDifferenceClockTime;
349
qDebug() << "cycle " << cycle;
350
qDebug() << "ns needed for set-building: repository-set: " << float(repositoryTime)
351
<< " generic-set: " << float(genericTime);
352
qDebug() << "ns needed for intersection: repository-sets: " << float(repositoryIntersectionTime)
353
<< " generic-set: " << float(genericIntersectionTime) << " QSet: " << float(qsetIntersectionTime);
354
qDebug() << "ns needed for union: repository-sets: " << float(repositoryUnionTime)
355
<< " generic-set: " << float(genericUnionTime);
356
qDebug() << "ns needed for difference: repository-sets: " << float(repositoryDifferenceTime)
357
<< " generic-set: " << float(genericDifferenceTime);