~ubuntu-branches/ubuntu/trusty/kdevplatform/trusty-proposed

« back to all changes in this revision

Viewing changes to language/duchain/tests/test_duchain.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2013-12-09 17:24:43 UTC
  • mfrom: (0.3.25)
  • Revision ID: package-import@ubuntu.com-20131209172443-rstb3roh6fj0c5vw
Tags: 1.6.0-0ubuntu1
* New upstream release (LP: #1259220)
* Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "test_duchain.h"
25
25
 
26
26
#include <QTest>
 
27
#include <QElapsedTimer>
 
28
 
27
29
#include <tests/autotestshell.h>
28
30
#include <tests/testcore.h>
29
31
 
31
33
#include <language/duchain/duchainlock.h>
32
34
#include <language/duchain/persistentsymboltable.h>
33
35
#include <language/duchain/codemodel.h>
 
36
#include <language/duchain/types/typesystemdata.h>
 
37
#include <language/duchain/types/integraltype.h>
 
38
#include <language/duchain/types/typeregister.h>
34
39
 
35
40
#include <language/codegen/coderepresentation.h>
36
41
 
38
43
#include <language/util/basicsetrepository.h>
39
44
 
40
45
// #include <typeinfo>
41
 
#include <time.h>
42
46
#include <set>
43
47
#include <algorithm>
44
48
#include <iterator> // needed for std::insert_iterator on windows
47
51
//Extremely slow
48
52
// #define TEST_NORMAL_IMPORTS
49
53
 
50
 
//Uncomment the following line to get additional output from the string-repository test
51
 
//#define DEBUG_STRINGREPOSITORY
52
 
 
53
54
QTEST_MAIN(TestDUChain)
54
55
 
55
56
using namespace KDevelop;
57
58
 
58
59
typedef BasicSetRepository::Index Index;
59
60
 
 
61
struct Timer
 
62
{
 
63
  Timer()
 
64
  {
 
65
    m_timer.start();
 
66
  }
 
67
  qint64 elapsed()
 
68
  {
 
69
    return m_timer.nsecsElapsed();
 
70
  }
 
71
  QElapsedTimer m_timer;
 
72
};
 
73
 
60
74
void TestDUChain::initTestCase()
61
75
{
62
76
  AutoTestShell::init();
73
87
 
74
88
void TestDUChain::testStringSets() {
75
89
 
76
 
  const unsigned int setCount = 11;
 
90
  const unsigned int setCount = 8;
77
91
  const unsigned int choiceCount = 40;
78
92
  const unsigned int itemCount = 120;
79
93
 
81
95
 
82
96
//  kDebug() << "Start repository-layout: \n" << rep.dumpDotGraph();
83
97
 
84
 
  clock_t repositoryClockTime = 0; //Time spent on repository-operations
85
 
  clock_t genericClockTime = 0; //Time spend on equivalent operations with generic sets
86
 
 
87
 
  clock_t repositoryIntersectionClockTime = 0; //Time spent on repository-operations
88
 
  clock_t genericIntersectionClockTime = 0; //Time spend on equivalent operations with generic sets
89
 
  clock_t qsetIntersectionClockTime = 0; //Time spend on equivalent operations with generic sets
90
 
 
91
 
  clock_t repositoryUnionClockTime = 0; //Time spent on repository-operations
92
 
  clock_t genericUnionClockTime = 0; //Time spend on equivalent operations with generic sets
93
 
 
94
 
  clock_t repositoryDifferenceClockTime = 0; //Time spent on repository-operations
95
 
  clock_t genericDifferenceClockTime = 0; //Time spend on equivalent operations with generic sets
 
98
  qint64 repositoryTime = 0; //Time spent on repository-operations
 
99
  qint64 genericTime = 0; //Time spend on equivalent operations with generic sets
 
100
 
 
101
  qint64 repositoryIntersectionTime = 0; //Time spent on repository-operations
 
102
  qint64 genericIntersectionTime = 0; //Time spend on equivalent operations with generic sets
 
103
  qint64 qsetIntersectionTime = 0; //Time spend on equivalent operations with generic sets
 
104
 
 
105
  qint64 repositoryUnionTime = 0; //Time spent on repository-operations
 
106
  qint64 genericUnionTime = 0; //Time spend on equivalent operations with generic sets
 
107
 
 
108
  qint64 repositoryDifferenceTime = 0; //Time spent on repository-operations
 
109
  qint64 genericDifferenceTime = 0; //Time spend on equivalent operations with generic sets
96
110
 
97
111
  Set sets[setCount];
98
112
  std::set<Index> realSets[setCount];
110
124
        choose = (rand() % itemCount) + 1;
111
125
      }
112
126
 
113
 
      clock_t c = clock();
 
127
      Timer t;
114
128
      chosenIndices.insert(chosenIndices.end(), choose);
115
 
      genericClockTime += clock() - c;
 
129
      genericTime += t.elapsed();
116
130
    }
117
131
 
118
 
    clock_t c = clock();
119
 
    sets[a] = rep.createSet(chosenIndices);
120
 
    repositoryClockTime += clock() - c;
 
132
    {
 
133
      Timer t;
 
134
      sets[a] = rep.createSet(chosenIndices);
 
135
      repositoryTime += t.elapsed();
 
136
    }
121
137
 
122
138
    realSets[a] = chosenIndices;
123
139
 
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);
130
 
      kDebug() << dbg;
 
146
      qDebug() << dbg;
131
147
 
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);
135
 
      kDebug() << dbg;
 
151
      qDebug() << dbg;
136
152
 
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!");
138
155
    }
139
 
    QVERIFY(tempSet == realSets[a]);
140
156
  }
141
157
 
142
158
  for(int cycle = 0; cycle < 100; ++cycle) {
143
159
      if(cycle % 10 == 0)
144
 
         kDebug() << "cycle" << cycle;
 
160
         qDebug() << "cycle" << cycle;
145
161
 
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;
150
 
        clock_t c = clock();
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;
 
166
        {
 
167
          Timer t;
 
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();
 
170
        }
153
171
 
154
 
        c = clock();
155
 
        Set _difference = sets[a] - sets[b];
156
 
        repositoryDifferenceClockTime += clock() - c;
 
172
        Set _difference;
 
173
        {
 
174
          Timer t;
 
175
          _difference = sets[a] - sets[b];
 
176
          repositoryDifferenceTime += t.elapsed();
 
177
        }
157
178
 
158
179
        if(_difference.stdSet() != _realDifference)
159
180
        {
160
181
          {
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);
165
 
            kDebug() << dbg;
 
186
            qDebug() << dbg;
166
187
 
167
 
            kDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
 
188
            qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
168
189
          }
169
190
          {
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);
174
 
            kDebug() << dbg;
 
195
            qDebug() << dbg;
175
196
 
176
 
            kDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
 
197
            qDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
177
198
          }
178
199
 
179
200
          {
180
201
            std::set<Index> tempSet = _difference.stdSet();
181
202
 
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);
186
 
            kDebug() << dbg;
 
207
            qDebug() << dbg;
187
208
 
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);
191
 
            kDebug() << dbg;
 
212
            qDebug() << dbg;
192
213
 
193
 
            kDebug() << "DOT-Graph:\n\n" << _difference.dumpDotGraph() << "\n\n";
 
214
            qDebug() << "DOT-Graph:\n\n" << _difference.dumpDotGraph() << "\n\n";
194
215
          }
 
216
          QFAIL("difference sets are not the same!");
195
217
        }
196
 
        QVERIFY(_difference.stdSet() == _realDifference);
197
218
 
198
219
 
199
220
        /// ------ UNION
200
221
 
201
222
        std::set<Index> _realUnion;
202
 
        c = clock();
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;
 
223
        {
 
224
          Timer t;
 
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();
 
227
        }
205
228
 
206
 
        c = clock();
207
 
        Set _union = sets[a] + sets[b];
208
 
        repositoryUnionClockTime += clock() - c;
 
229
        Set _union;
 
230
        {
 
231
          Timer t;
 
232
          _union = sets[a] + sets[b];
 
233
          repositoryUnionTime += t.elapsed();
 
234
        }
209
235
 
210
236
        if(_union.stdSet() != _realUnion)
211
237
        {
212
238
          {
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);
217
 
            kDebug() << dbg;
 
243
            qDebug() << dbg;
218
244
 
219
 
            kDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
 
245
            qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
220
246
          }
221
247
          {
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);
226
 
            kDebug() << dbg;
 
252
            qDebug() << dbg;
227
253
 
228
 
            kDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
 
254
            qDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
229
255
          }
230
256
 
231
257
          {
232
258
            std::set<Index> tempSet = _union.stdSet();
233
259
 
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);
238
 
            kDebug() << dbg;
 
264
            qDebug() << dbg;
239
265
 
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);
243
 
            kDebug() << dbg;
 
269
            qDebug() << dbg;
244
270
 
245
 
            kDebug() << "DOT-Graph:\n\n" << _union.dumpDotGraph() << "\n\n";
 
271
            qDebug() << "DOT-Graph:\n\n" << _union.dumpDotGraph() << "\n\n";
246
272
          }
 
273
 
 
274
          QFAIL("union sets are not the same");
247
275
        }
248
 
        QVERIFY(_union.stdSet() == _realUnion);
249
276
 
250
277
        std::set<Index> _realIntersection;
251
278
 
252
279
        /// -------- INTERSECTION
253
 
        c = clock();
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;
 
280
        {
 
281
          Timer t;
 
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();
 
284
        }
256
285
 
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)
 
290
        }
 
291
        for(std::set<Index>::const_iterator it = realSets[b].begin(); it != realSets[b].end(); ++it) {
262
292
          second.insert(*it);
263
 
        c = clock();
264
 
        QSet<Index> i = first.intersect(second);
265
 
        qsetIntersectionClockTime += clock() - c;
266
 
 
267
 
        c = clock();
268
 
        Set _intersection = sets[a] & sets[b];
269
 
        repositoryIntersectionClockTime += clock() - c;
270
 
 
 
293
        }
 
294
        {
 
295
          Timer t;
 
296
          QSet<Index> i = first.intersect(second);
 
297
          qsetIntersectionTime += t.elapsed();
 
298
        }
 
299
 
 
300
        Set _intersection;
 
301
        {
 
302
          Timer t;
 
303
          _intersection = sets[a] & sets[b];
 
304
          repositoryIntersectionTime += t.elapsed();
 
305
        }
271
306
 
272
307
        if(_intersection.stdSet() != _realIntersection)
273
308
        {
274
309
          {
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);
279
 
            kDebug() << dbg;
 
314
            qDebug() << dbg;
280
315
 
281
 
            kDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
 
316
            qDebug() << "DOT-Graph:\n\n" << sets[a].dumpDotGraph() << "\n\n";
282
317
          }
283
318
          {
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);
288
 
            kDebug() << dbg;
 
323
            qDebug() << dbg;
289
324
 
290
 
            kDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
 
325
            qDebug() << "DOT-Graph:\n\n" << sets[b].dumpDotGraph() << "\n\n";
291
326
          }
292
327
 
293
328
          {
294
329
            std::set<Index> tempSet = _intersection.stdSet();
295
330
 
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);
300
 
            kDebug() << dbg;
 
335
            qDebug() << dbg;
301
336
 
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);
305
 
            kDebug() << dbg;
 
340
            qDebug() << dbg;
306
341
 
307
 
            kDebug() << "DOT-Graph:\n\n" << _intersection.dumpDotGraph() << "\n\n";
 
342
            qDebug() << "DOT-Graph:\n\n" << _intersection.dumpDotGraph() << "\n\n";
308
343
          }
 
344
          QFAIL("intersection sets are not the same");
309
345
        }
310
 
        QVERIFY(_intersection.stdSet() == _realIntersection);
311
346
      }
312
347
    }
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;
319
 
#endif
 
348
 
 
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);
320
358
  }
321
359
}
322
360
 
475
513
  reachableNodes.insert(currentNode);
476
514
  const Utils::SetNodeData* node = KDevelop::RecursiveImportRepository::repository()->nodeFromIndex(currentNode);
477
515
  Q_ASSERT(node);
478
 
  collectReachableNodes(reachableNodes, node->leftNode);
479
 
  collectReachableNodes(reachableNodes, node->rightNode);
 
516
  collectReachableNodes(reachableNodes, node->leftNode());
 
517
  collectReachableNodes(reachableNodes, node->rightNode());
480
518
}
481
519
 
482
520
uint collectNaiveNodeCount(uint currentNode) {
485
523
  uint ret = 1;
486
524
  const Utils::SetNodeData* node = KDevelop::RecursiveImportRepository::repository()->nodeFromIndex(currentNode);
487
525
  Q_ASSERT(node);
488
 
  ret += collectNaiveNodeCount(node->leftNode);
489
 
  ret += collectNaiveNodeCount(node->rightNode);
 
526
  ret += collectNaiveNodeCount(node->leftNode());
 
527
  ret += collectNaiveNodeCount(node->rightNode());
490
528
  return ret;
491
529
}
492
530
 
493
531
void TestDUChain::testImportStructure()
494
532
{
495
 
  clock_t startClock = clock();
 
533
  Timer total;
496
534
  kDebug() << "before: " << KDevelop::RecursiveImportRepository::repository()->getDataRepository().statistics().print();
497
535
 
498
536
  ///Maintains a naive import-structure along with a real top-context import structure, and allows comparing both.
502
540
  for(int t = 0; t < cycles; ++t) {
503
541
    QList<TestContext*> allContexts;
504
542
    //Create a random structure
505
 
    int contextCount = 120;
506
 
    int verifyOnceIn = contextCount/*((contextCount*contextCount)/20)+1*/; //Verify once in every chances(not in all cases, becase else the import-structure isn't built on-demand!)
 
543
    int contextCount = 50;
 
544
    int verifyOnceIn = contextCount/*((contextCount*contextCount)/20)+1*/; //Verify once in every chances(not in all cases, because else the import-structure isn't built on-demand!)
507
545
    int clearOnceIn = contextCount;
508
546
    for(int a = 0; a < contextCount; a++)
509
547
      allContexts << new TestContext();
549
587
      }
550
588
    }
551
589
 
552
 
  kDebug() << "after: " << KDevelop::RecursiveImportRepository::repository()->getDataRepository().statistics().print();
553
 
 
554
 
  for(int a = 0; a < contextCount; ++a)
555
 
    delete allContexts[a];
556
 
  allContexts.clear();
557
 
  kDebug() << "after cleanup: " << KDevelop::RecursiveImportRepository::repository()->getDataRepository().statistics().print();
558
 
 
 
590
    kDebug() << "after: " << KDevelop::RecursiveImportRepository::repository()->getDataRepository().statistics().print();
 
591
 
 
592
    for(int a = 0; a < contextCount; ++a)
 
593
      delete allContexts[a];
 
594
    allContexts.clear();
 
595
    kDebug() << "after cleanup: " << KDevelop::RecursiveImportRepository::repository()->getDataRepository().statistics().print();
559
596
  }
560
 
  clock_t endClock = clock();
561
 
  kDebug() << "total clock cycles needed for import-structure test:" << endClock - startClock;
 
597
  qDebug() << "total ns needed for import-structure test:" << float(total.elapsed());
562
598
}
563
599
 
564
600
class TestWorker : public QObject
717
753
  }
718
754
}
719
755
 
 
756
void TestDUChain::benchTypeRegistry()
 
757
{
 
758
  IntegralTypeData data;
 
759
  data.m_dataType = IntegralType::TypeInt;
 
760
  data.typeClassId = IntegralType::Identity;
 
761
  data.inRepository = false;
 
762
  data.m_modifiers = 42;
 
763
  data.m_dynamic = false;
 
764
  data.refCount = 1;
 
765
 
 
766
  IntegralTypeData to;
 
767
 
 
768
  QFETCH(int, func);
 
769
 
 
770
  QBENCHMARK {
 
771
    switch(func) {
 
772
      case 0:
 
773
        TypeSystem::self().dataClassSize(data);
 
774
        break;
 
775
      case 1:
 
776
        TypeSystem::self().dynamicSize(data);
 
777
        break;
 
778
      case 2:
 
779
        TypeSystem::self().create(&data);
 
780
        break;
 
781
      case 3:
 
782
        TypeSystem::self().isFactoryLoaded(data);
 
783
        break;
 
784
      case 4:
 
785
        TypeSystem::self().copy(data, to, !data.m_dynamic);
 
786
        break;
 
787
      case 5:
 
788
        TypeSystem::self().copy(data, to, data.m_dynamic);
 
789
        break;
 
790
      case 6:
 
791
        TypeSystem::self().callDestructor(&data);
 
792
        break;
 
793
    }
 
794
  }
 
795
}
 
796
 
 
797
void TestDUChain::benchTypeRegistry_data()
 
798
{
 
799
  QTest::addColumn<int>("func");
 
800
  QTest::newRow("dataClassSize") << 0;
 
801
  QTest::newRow("dynamicSize") << 1;
 
802
  QTest::newRow("create") << 2;
 
803
  QTest::newRow("isFactoryLoaded") << 3;
 
804
  QTest::newRow("copy") << 4;
 
805
  QTest::newRow("copyNonDynamic") << 5;
 
806
  QTest::newRow("callDestructor") << 6;
 
807
}
 
808
 
720
809
#include "test_duchain.moc"
721
810
#include "moc_test_duchain.cpp"