1 // Created on: 2004-03-05
2 // Created by: Mikhail KUZMITCHEV
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <QANCollection.hxx>
17 #include <QANCollection_Common.hxx>
20 #include <Draw_Interpretor.hxx>
22 #include <TColgp_Array1OfPnt.hxx>
23 #include <TColgp_Array2OfPnt.hxx>
24 #include <TColStd_MapOfReal.hxx>
25 #include <TColStd_IndexedMapOfReal.hxx>
26 #include <TColgp_SequenceOfPnt.hxx>
28 #include <QANCollection_DataMapOfRealPnt.hxx>
29 #include <QANCollection_DoubleMapOfRealInteger.hxx>
30 #include <QANCollection_IndexedDataMapOfRealPnt.hxx>
31 #include <QANCollection_ListOfPnt.hxx>
33 #include <NCollection_SparseArray.hxx>
34 #include <NCollection_SparseArrayBase.hxx>
36 #define PERF_ENABLE_METERS
37 #include <OSD_PerfMeter.hxx>
39 #define ItemType gp_Pnt
40 #define Key1Type Standard_Real
41 #define Key2Type Standard_Integer
43 // ===================== INSTANTIATIONS ===========
44 // ===================== The Types must be defined before this line ===========
45 // These are: TheItemType, TheKey1Type, TheKey2Type
46 // So must be defined ::HashCode and ::IsEqual too
48 #include <NCollection_DefineArray1.hxx>
49 #include <NCollection_DefineHArray1.hxx>
50 ////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType)
51 ////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1)
52 DEFINE_ARRAY1(QANCollection_Array1Perf,QANCollection_BaseColPerf,ItemType)
53 DEFINE_HARRAY1(QANCollection_HArray1Perf,QANCollection_Array1Perf)
55 #include <NCollection_DefineArray2.hxx>
56 #include <NCollection_DefineHArray2.hxx>
57 ////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType)
58 ////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2)
59 DEFINE_ARRAY2(QANCollection_Array2Perf,QANCollection_BaseColPerf,ItemType)
60 DEFINE_HARRAY2(QANCollection_HArray2Perf,QANCollection_Array2Perf)
62 #include <NCollection_DefineMap.hxx>
63 #include <NCollection_DefineDataMap.hxx>
64 #include <NCollection_DefineDoubleMap.hxx>
65 #include <NCollection_DefineIndexedMap.hxx>
66 #include <NCollection_DefineIndexedDataMap.hxx>
67 ////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type)
68 ////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType)
69 ////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type)
70 ////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type)
71 ////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType)
72 DEFINE_MAP(QANCollection_MapPerf,QANCollection_Key1BaseColPerf,Key1Type)
73 DEFINE_DATAMAP(QANCollection_DataMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
74 DEFINE_DOUBLEMAP(QANCollection_DoubleMapPerf,QANCollection_Key2BaseColPerf,Key1Type,Key2Type)
75 DEFINE_INDEXEDMAP(QANCollection_IndexedMapPerf,QANCollection_Key1BaseColPerf,Key1Type)
76 DEFINE_INDEXEDDATAMAP(QANCollection_IDMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
78 #include <NCollection_DefineList.hxx>
79 ////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
80 DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType)
82 #include <NCollection_DefineSequence.hxx>
83 #include <NCollection_DefineHSequence.hxx>
84 ////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType)
85 ////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence)
86 DEFINE_SEQUENCE(QANCollection_SequencePerf,QANCollection_BaseColPerf,ItemType)
87 DEFINE_HSEQUENCE(QANCollection_HSequencePerf,QANCollection_SequencePerf)
89 static void printAllMeters (Draw_Interpretor& theDI)
92 perf_sprint_all_meters (buffer, 25600 - 1, 1);
96 // ===================== Test perform of Array1 type ==========================
97 static void CompArray1 (Draw_Interpretor& theDI,
98 const Standard_Integer theRep,
99 const Standard_Integer theSize)
101 Standard_Integer i,j;
103 ////////////////////////////////Perf_Meter aNCrea ("NCollection_Array1 creation",0);
104 ////////////////////////////////Perf_Meter aTCrea ("TCollection_Array1 creation",0);
105 ////////////////////////////////Perf_Meter aNFill ("NCollection_Array1 filling",0);
106 ////////////////////////////////Perf_Meter aTFill ("TCollection_Array1 filling",0);
107 ////////////////////////////////Perf_Meter aNFind ("NCollection_Array1 finding",0);
108 ////////////////////////////////Perf_Meter aTFind ("TCollection_Array1 finding",0);
109 ////////////////////////////////Perf_Meter aNOper ("NCollection_Array1 operator=",0);
110 ////////////////////////////////Perf_Meter aTOper ("TCollection_Array1 operator=",0);
111 ////////////////////////////////Perf_Meter aNAssi ("NCollection_Array1 Assign",0);
112 for (i=0; i<theRep; i++)
114 ////////////////////////////////aNCrea.Start();
115 PERF_START_METER("NCollection_Array1 creation")
116 ////////////////////////////////QANCollection_Array1 a1(1,theSize), a2(1,theSize);
117 QANCollection_Array1Perf a1(1,theSize), a2(1,theSize);
118 ////////////////////////////////aNCrea.Stop();
119 PERF_STOP_METER("NCollection_Array1 creation")
120 ////////////////////////////////aNFill.Start();
121 PERF_START_METER("NCollection_Array1 filling")
122 for (j=1; j<=theSize; j++)
124 ////////////////////////////////aNFill.Stop();
125 PERF_STOP_METER("NCollection_Array1 filling")
126 ////////////////////////////////aNFind.Start();
127 PERF_START_METER("NCollection_Array1 finding")
128 for (j=1; j<=theSize; j++)
130 Standard_Integer iIndex;
131 Random(iIndex,theSize);
134 ////////////////////////////////aNFind.Stop();
135 PERF_STOP_METER("NCollection_Array1 finding")
136 ////////////////////////////////aNOper.Start();
137 PERF_START_METER("NCollection_Array1 operator=")
139 ////////////////////////////////aNOper.Stop();
140 PERF_STOP_METER("NCollection_Array1 operator=")
141 ////////////////////////////////aNAssi.Start();
142 PERF_START_METER("NCollection_Array1 Assign")
144 ////////////////////////////////aNAssi.Stop();
145 PERF_STOP_METER("NCollection_Array1 Assign")
148 for (i=0; i<theRep; i++)
150 ////////////////////////////////aTCrea.Start();
151 PERF_START_METER("TCollection_Array1 creation")
152 TColgp_Array1OfPnt a1(1,theSize), a2(1,theSize);
153 ////////////////////////////////aTCrea.Stop();
154 PERF_STOP_METER("TCollection_Array1 creation")
155 ////////////////////////////////aTFill.Start();
156 PERF_START_METER("TCollection_Array1 filling")
157 for (j=1; j<=theSize; j++)
159 ////////////////////////////////aTFill.Stop();
160 PERF_STOP_METER("TCollection_Array1 filling")
161 ////////////////////////////////aTFind.Start();
162 PERF_START_METER("TCollection_Array1 finding")
163 for (j=1; j<=theSize; j++)
165 Standard_Integer iIndex;
166 Random(iIndex,theSize);
169 ////////////////////////////////aTFind.Stop();
170 PERF_STOP_METER("TCollection_Array1 finding")
171 ////////////////////////////////aTOper.Start();
172 PERF_START_METER("TCollection_Array1 operator=")
174 ////////////////////////////////aTOper.Stop();
175 PERF_STOP_METER("TCollection_Array1 operator=")
177 printAllMeters(theDI);
180 // ===================== Test perform of Array2 type ==========================
181 static void CompArray2 (Draw_Interpretor& theDI,
182 const Standard_Integer theRep,
183 const Standard_Integer theSize)
185 Standard_Integer i,j,k;
187 ////////////////////////////////Perf_Meter aNCrea ("NCollection_Array2 creation",0);
188 ////////////////////////////////Perf_Meter aTCrea ("TCollection_Array2 creation",0);
189 ////////////////////////////////Perf_Meter aNFill ("NCollection_Array2 filling",0);
190 ////////////////////////////////Perf_Meter aTFill ("TCollection_Array2 filling",0);
191 ////////////////////////////////Perf_Meter aNFind ("NCollection_Array2 finding",0);
192 ////////////////////////////////Perf_Meter aTFind ("TCollection_Array2 finding",0);
193 ////////////////////////////////Perf_Meter aNOper ("NCollection_Array2 operator=",0);
194 ////////////////////////////////Perf_Meter aTOper ("TCollection_Array2 operator=",0);
195 ////////////////////////////////Perf_Meter aNAssi ("NCollection_Array2 Assign",0);
196 for (i=0; i<theRep; i++)
198 ////////////////////////////////aNCrea.Start();
199 PERF_START_METER("NCollection_Array2 creation")
200 ////////////////////////////////QANCollection_Array2 a1(1,theSize,1,theSize), a2(1,theSize,1,theSize);
201 QANCollection_Array2Perf a1(1,theSize,1,theSize), a2(1,theSize,1,theSize);
202 ////////////////////////////////aNCrea.Stop();
203 PERF_STOP_METER("NCollection_Array2 creation")
204 ////////////////////////////////aNFill.Start();
205 PERF_START_METER("NCollection_Array2 filling")
206 for (j=1; j<=theSize; j++)
207 for (k=1; k<=theSize; k++)
209 ////////////////////////////////aNFill.Stop();
210 PERF_STOP_METER("NCollection_Array2 filling")
211 ////////////////////////////////aNFind.Start();
212 PERF_START_METER("NCollection_Array2 finding")
213 for (j=1; j<=theSize*theSize; j++)
215 Standard_Integer m,n;
220 ////////////////////////////////aNFind.Stop();
221 PERF_STOP_METER("NCollection_Array2 finding")
222 ////////////////////////////////aNOper.Start();
223 PERF_START_METER("NCollection_Array2 operator=")
225 ////////////////////////////////aNOper.Stop();
226 PERF_STOP_METER("NCollection_Array2 operator=")
227 ////////////////////////////////aNAssi.Start();
228 PERF_START_METER("NCollection_Array2 Assign")
230 ////////////////////////////////aNAssi.Stop();
231 PERF_STOP_METER("NCollection_Array2 Assign")
234 for (i=0; i<theRep; i++)
236 ////////////////////////////////aTCrea.Start();
237 PERF_START_METER("TCollection_Array2 creation")
238 TColgp_Array2OfPnt a1(1,theSize,1,theSize), a2(1,theSize,1,theSize);
239 ////////////////////////////////aTCrea.Stop();
240 PERF_STOP_METER("TCollection_Array2 creation")
241 ////////////////////////////////aTFill.Start();
242 PERF_START_METER("TCollection_Array2 filling")
243 for (j=1; j<=theSize; j++)
244 for (k=1; k<=theSize; k++)
246 ////////////////////////////////aTFill.Stop();
247 PERF_STOP_METER("TCollection_Array2 filling")
248 ////////////////////////////////aTFind.Start();
249 PERF_START_METER("TCollection_Array2 finding")
250 for (j=1; j<=theSize*theSize; j++)
252 Standard_Integer m,n;
257 ////////////////////////////////aTFind.Stop();
258 PERF_STOP_METER("TCollection_Array2 finding")
259 ////////////////////////////////aTOper.Start();
260 PERF_START_METER("TCollection_Array2 operator=")
262 ////////////////////////////////aTOper.Stop();
263 PERF_STOP_METER("TCollection_Array2 operator=")
265 printAllMeters(theDI);
268 // ===================== Test perform of List type ==========================
269 static void CompList (Draw_Interpretor& theDI,
270 const Standard_Integer theRep,
271 const Standard_Integer theSize)
273 Standard_Integer i,j;
275 ////////////////////////////////Perf_Meter aNAppe ("NCollection_List appending",0);
276 ////////////////////////////////Perf_Meter aTAppe ("TCollection_List appending",0);
277 ////////////////////////////////Perf_Meter aNOper ("NCollection_List operator=",0);
278 ////////////////////////////////Perf_Meter aTOper ("TCollection_List operator=",0);
279 ////////////////////////////////Perf_Meter aNClea ("NCollection_List clearing",0);
280 ////////////////////////////////Perf_Meter aTClea ("TCollection_List clearing",0);
281 ////////////////////////////////Perf_Meter aNAssi ("NCollection_List Assign",0);
282 for (i=0; i<theRep; i++)
284 ////////////////////////////////QANCollection_List a1, a2;
285 QANCollection_ListPerf a1, a2;
286 ////////////////////////////////aNAppe.Start();
287 PERF_START_METER("NCollection_List appending")
288 for (j=1; j<=theSize; j++)
294 ////////////////////////////////aNAppe.Stop();
295 PERF_STOP_METER("NCollection_List appending")
296 ////////////////////////////////aNOper.Start();
297 PERF_START_METER("NCollection_List operator=")
299 ////////////////////////////////aNOper.Stop();
300 PERF_STOP_METER("NCollection_List operator=")
301 ////////////////////////////////aNAssi.Start();
302 PERF_START_METER("NCollection_List Assign")
304 ////////////////////////////////aNAssi.Stop();
305 PERF_STOP_METER("NCollection_List Assign")
306 ////////////////////////////////aNClea.Start();
307 PERF_START_METER("NCollection_List clearing")
309 ////////////////////////////////aNClea.Stop();
310 PERF_STOP_METER("NCollection_List clearing")
313 for (i=0; i<theRep; i++)
315 QANCollection_ListOfPnt a1, a2;
316 ////////////////////////////////aTAppe.Start();
317 PERF_START_METER("TCollection_List appending")
318 for (j=1; j<=theSize; j++)
324 ////////////////////////////////aTAppe.Stop();
325 PERF_STOP_METER("TCollection_List appending")
326 ////////////////////////////////aTOper.Start();
327 PERF_START_METER("TCollection_List operator=")
329 ////////////////////////////////aTOper.Stop();
330 PERF_STOP_METER("TCollection_List operator=")
331 ////////////////////////////////aTClea.Start();
332 PERF_START_METER("TCollection_List clearing")
334 ////////////////////////////////aTClea.Stop();
335 PERF_STOP_METER("TCollection_List clearing")
337 printAllMeters(theDI);
340 // ===================== Test perform of Sequence type ==========================
341 static void CompSequence (Draw_Interpretor& theDI,
342 const Standard_Integer theRep,
343 const Standard_Integer theSize)
345 Standard_Integer i,j;
347 ////////////////////////////////Perf_Meter aNAppe ("NCollection_Sequence appending",0);
348 ////////////////////////////////Perf_Meter aTAppe ("TCollection_Sequence appending",0);
349 ////////////////////////////////Perf_Meter aNFind ("NCollection_Sequence finding",0);
350 ////////////////////////////////Perf_Meter aTFind ("TCollection_Sequence finding",0);
351 ////////////////////////////////Perf_Meter aNOper ("NCollection_Sequence operator=",0);
352 ////////////////////////////////Perf_Meter aTOper ("TCollection_Sequence operator=",0);
353 ////////////////////////////////Perf_Meter aNClea ("NCollection_Sequence clearing",0);
354 ////////////////////////////////Perf_Meter aTClea ("TCollection_Sequence clearing",0);
355 ////////////////////////////////Perf_Meter aNAssi ("NCollection_Sequence Assign",0);
356 for (i=0; i<theRep; i++)
358 ////////////////////////////////QANCollection_Sequence a1, a2;
359 QANCollection_SequencePerf a1, a2;
360 ////////////////////////////////aNAppe.Start();
361 PERF_START_METER("NCollection_Sequence appending")
362 for (j=1; j<=theSize; j++)
368 ////////////////////////////////aNAppe.Stop();
369 PERF_STOP_METER("NCollection_Sequence appending")
370 ////////////////////////////////aNFind.Start();
371 PERF_START_METER("NCollection_Sequence finding")
372 for (j=1; j<=theSize; j++)
374 Standard_Integer iIndex;
375 Random(iIndex,theSize);
378 ////////////////////////////////aNFind.Stop();
379 PERF_STOP_METER("NCollection_Sequence finding")
380 ////////////////////////////////aNOper.Start();
381 PERF_START_METER("NCollection_Sequence operator=")
383 ////////////////////////////////aNOper.Stop();
384 PERF_STOP_METER("NCollection_Sequence operator=")
385 ////////////////////////////////aNAssi.Start();
386 PERF_START_METER("NCollection_Sequence Assign")
388 ////////////////////////////////aNAssi.Stop();
389 PERF_STOP_METER("NCollection_Sequence Assign")
390 ////////////////////////////////aNClea.Start();
391 PERF_START_METER("NCollection_Sequence clearing")
393 ////////////////////////////////aNClea.Stop();
394 PERF_STOP_METER("NCollection_Sequence clearing")
397 for (i=0; i<theRep; i++)
399 TColgp_SequenceOfPnt a1, a2;
400 ////////////////////////////////aTAppe.Start();
401 PERF_START_METER("TCollection_Sequence appending")
402 for (j=1; j<=theSize; j++)
408 ////////////////////////////////aTAppe.Stop();
409 PERF_STOP_METER("TCollection_Sequence appending")
410 ////////////////////////////////aTFind.Start();
411 PERF_START_METER("TCollection_Sequence finding")
412 for (j=1; j<=theSize; j++)
414 Standard_Integer iIndex;
415 Random(iIndex,theSize);
418 ////////////////////////////////aTFind.Stop();
419 PERF_STOP_METER("TCollection_Sequence finding")
420 ////////////////////////////////aTOper.Start();
421 PERF_START_METER("TCollection_Sequence operator=")
423 ////////////////////////////////aTOper.Stop();
424 PERF_STOP_METER("TCollection_Sequence operator=")
425 ////////////////////////////////aTClea.Start();
426 PERF_START_METER("TCollection_Sequence clearing")
428 ////////////////////////////////aTClea.Stop();
429 PERF_STOP_METER("TCollection_Sequence clearing")
431 printAllMeters(theDI);
434 // ===================== Test perform of Map type ==========================
435 static void CompMap (Draw_Interpretor& theDI,
436 const Standard_Integer theRep,
437 const Standard_Integer theSize)
439 Standard_Integer i,j;
441 ////////////////////////////////Perf_Meter aNBind ("NCollection_Map adding",0);
442 ////////////////////////////////Perf_Meter aTBind ("TCollection_Map adding",0);
443 ////////////////////////////////Perf_Meter aNOper ("NCollection_Map operator=",0);
444 ////////////////////////////////Perf_Meter aTOper ("TCollection_Map operator=",0);
445 ////////////////////////////////Perf_Meter aNFind ("NCollection_Map finding",0);
446 ////////////////////////////////Perf_Meter aTFind ("TCollection_Map finding",0);
447 ////////////////////////////////Perf_Meter aNClea ("NCollection_Map clearing",0);
448 ////////////////////////////////Perf_Meter aTClea ("TCollection_Map clearing",0);
449 ////////////////////////////////Perf_Meter aNAssi ("NCollection_Map Assign",0);
450 for (i=0; i<theRep; i++)
452 ////////////////////////////////QANCollection_Map a1, a2;
453 QANCollection_MapPerf a1, a2;
454 ////////////////////////////////aNBind.Start();
455 PERF_START_METER("NCollection_Map adding")
456 for (j=1; j<=theSize; j++)
462 ////////////////////////////////aNBind.Stop();
463 PERF_STOP_METER("NCollection_Map adding")
464 ////////////////////////////////aNFind.Start();
465 PERF_START_METER("NCollection_Map finding")
466 for (j=1; j<=theSize; j++)
472 ////////////////////////////////aNFind.Stop();
473 PERF_STOP_METER("NCollection_Map finding")
474 ////////////////////////////////aNOper.Start();
475 PERF_START_METER("NCollection_Map operator=")
477 ////////////////////////////////aNOper.Stop();
478 PERF_STOP_METER("NCollection_Map operator=")
479 ////////////////////////////////aNAssi.Start();
480 PERF_START_METER("NCollection_Map Assign")
482 ////////////////////////////////aNAssi.Stop();
483 PERF_STOP_METER("NCollection_Map Assign")
484 ////////////////////////////////aNClea.Start();
485 PERF_START_METER("NCollection_Map clearing")
487 ////////////////////////////////aNClea.Stop();
488 PERF_STOP_METER("NCollection_Map clearing")
491 for (i=0; i<theRep; i++)
493 TColStd_MapOfReal a1, a2;
494 ////////////////////////////////aTBind.Start();
495 PERF_START_METER("TCollection_Map adding")
496 for (j=1; j<=theSize; j++)
502 ////////////////////////////////aTBind.Stop();
503 PERF_STOP_METER("TCollection_Map adding")
504 ////////////////////////////////aTFind.Start();
505 PERF_START_METER("TCollection_Map finding")
506 for (j=1; j<=theSize; j++)
512 ////////////////////////////////aTFind.Stop();
513 PERF_STOP_METER("TCollection_Map finding")
514 ////////////////////////////////aTOper.Start();
515 PERF_START_METER("TCollection_Map operator=")
517 ////////////////////////////////aTOper.Stop();
518 PERF_STOP_METER("TCollection_Map operator=")
519 ////////////////////////////////aTClea.Start();
520 PERF_START_METER("TCollection_Map clearing")
522 ////////////////////////////////aTClea.Stop();
523 PERF_STOP_METER("TCollection_Map clearing")
525 printAllMeters(theDI);
528 // ===================== Test perform of DataMap type ==========================
529 static void CompDataMap (Draw_Interpretor& theDI,
530 const Standard_Integer theRep,
531 const Standard_Integer theSize)
533 Standard_Integer i,j;
535 ////////////////////////////////Perf_Meter aNBind ("NCollection_DataMap binding",0);
536 ////////////////////////////////Perf_Meter aTBind ("TCollection_DataMap binding",0);
537 ////////////////////////////////Perf_Meter aNFind ("NCollection_DataMap finding",0);
538 ////////////////////////////////Perf_Meter aTFind ("TCollection_DataMap finding",0);
539 ////////////////////////////////Perf_Meter aNOper ("NCollection_DataMap operator=",0);
540 ////////////////////////////////Perf_Meter aTOper ("TCollection_DataMap operator=",0);
541 ////////////////////////////////Perf_Meter aNClea ("NCollection_DataMap clearing",0);
542 ////////////////////////////////Perf_Meter aTClea ("TCollection_DataMap clearing",0);
543 //////////////////////////////////Perf_Meter aNAssi ("NCollection_DataMap Assign",0);
544 for (i=0; i<theRep; i++)
546 ////////////////////////////////QANCollection_DataMap a1, a2;
547 QANCollection_DataMapPerf a1, a2;
548 ////////////////////////////////aNBind.Start();
549 PERF_START_METER("NCollection_DataMap binding")
550 for (j=1; j<=theSize; j++)
556 a1.Bind(aKey1,anItem);
558 ////////////////////////////////aNBind.Stop();
559 PERF_STOP_METER("NCollection_DataMap binding")
560 ////////////////////////////////aNFind.Start();
561 PERF_START_METER("NCollection_DataMap finding")
562 for (j=1; j<=theSize; j++)
568 ////////////////////////////////aNFind.Stop();
569 PERF_STOP_METER("NCollection_DataMap finding")
570 ////////////////////////////////aNOper.Start();
571 PERF_START_METER("NCollection_DataMap operator=")
573 ////////////////////////////////aNOper.Stop();
574 PERF_STOP_METER("NCollection_DataMap operator=")
578 ////////////////////////////////aNClea.Start();
579 PERF_START_METER("NCollection_DataMap clearing")
581 ////////////////////////////////aNClea.Stop();
582 PERF_STOP_METER("NCollection_DataMap clearing")
585 for (i=0; i<theRep; i++)
587 QANCollection_DataMapOfRealPnt a1, a2;
588 ////////////////////////////////aTBind.Start();
589 PERF_START_METER("TCollection_DataMap binding")
590 for (j=1; j<=theSize; j++)
596 a1.Bind(aKey1,anItem);
598 ////////////////////////////////aTBind.Stop();
599 PERF_STOP_METER("TCollection_DataMap binding")
600 ////////////////////////////////aTFind.Start();
601 PERF_START_METER("TCollection_DataMap finding")
602 for (j=1; j<=theSize; j++)
608 ////////////////////////////////aTFind.Stop();
609 PERF_STOP_METER("TCollection_DataMap finding")
610 ////////////////////////////////aTOper.Start();
611 PERF_START_METER("TCollection_DataMap operator=")
613 ////////////////////////////////aTOper.Stop();
614 PERF_STOP_METER("TCollection_DataMap operator=")
615 ////////////////////////////////aTClea.Start();
616 PERF_START_METER("TCollection_DataMap clearing")
618 ////////////////////////////////aTClea.Stop();
619 PERF_STOP_METER("TCollection_DataMap clearing")
621 printAllMeters(theDI);
624 // ===================== Test perform of DoubleMap type ==========================
625 static void CompDoubleMap (Draw_Interpretor& theDI,
626 const Standard_Integer theRep,
627 const Standard_Integer theSize)
629 Standard_Integer i,j;
630 Standard_Integer iFail1=0, iFail2=0;
632 ////////////////////////////////Perf_Meter aNBind ("NCollection_DoubleMap binding",0);
633 ////////////////////////////////Perf_Meter aTBind ("TCollection_DoubleMap binding",0);
634 ////////////////////////////////Perf_Meter aNFind ("NCollection_DoubleMap finding",0);
635 ////////////////////////////////Perf_Meter aTFind ("TCollection_DoubleMap finding",0);
636 ////////////////////////////////Perf_Meter aNOper ("NCollection_DoubleMap operator=",0);
637 ////////////////////////////////Perf_Meter aTOper ("TCollection_DoubleMap operator=",0);
638 ////////////////////////////////Perf_Meter aNClea ("NCollection_DoubleMap clearing",0);
639 ////////////////////////////////Perf_Meter aTClea ("TCollection_DoubleMap clearing",0);
640 //////////////////////////////////Perf_Meter aNAssi ("NCollection_DoubleMap Assign",0);
641 for (i=0; i<theRep; i++)
643 ////////////////////////////////QANCollection_DoubleMap a1, a2;
644 QANCollection_DoubleMapPerf a1, a2;
645 ////////////////////////////////aNBind.Start();
646 PERF_START_METER("NCollection_DoubleMap binding")
647 for (j=1; j<=theSize; j++)
656 while (a1.IsBound1(aKey1) || a1.IsBound2(aKey2));
658 a1.Bind(aKey1,aKey2);
660 ////////////////////////////////aNBind.Stop();
661 PERF_STOP_METER("NCollection_DoubleMap binding")
662 ////////////////////////////////aNFind.Start();
663 PERF_START_METER("NCollection_DoubleMap finding")
664 for (j=1; j<=theSize; j++)
670 a1.AreBound(aKey1,aKey2);
672 ////////////////////////////////aNFind.Stop();
673 PERF_STOP_METER("NCollection_DoubleMap finding")
674 ////////////////////////////////aNOper.Start();
675 PERF_START_METER("NCollection_DoubleMap operator=")
677 ////////////////////////////////aNOper.Stop();
678 PERF_STOP_METER("NCollection_DoubleMap operator=")
682 ////////////////////////////////aNClea.Start();
683 PERF_START_METER("NCollection_DoubleMap clearing")
685 ////////////////////////////////aNClea.Stop();
686 PERF_STOP_METER("NCollection_DoubleMap clearing")
689 for (i=0; i<theRep; i++)
691 QANCollection_DoubleMapOfRealInteger a1, a2;
692 ////////////////////////////////aTBind.Start();
693 PERF_START_METER("TCollection_DoubleMap binding")
694 for (j=1; j<=theSize; j++)
703 while (a1.IsBound1(aKey1) || a1.IsBound2(aKey2));
705 a1.Bind(aKey1,aKey2);
707 ////////////////////////////////aTBind.Stop();
708 PERF_STOP_METER("TCollection_DoubleMap binding")
709 ////////////////////////////////aTFind.Start();
710 PERF_START_METER("TCollection_DoubleMap finding")
711 for (j=1; j<=theSize; j++)
717 a1.AreBound(aKey1,aKey2);
719 ////////////////////////////////aTFind.Stop();
720 PERF_STOP_METER("TCollection_DoubleMap finding")
721 ////////////////////////////////aTOper.Start();
722 PERF_START_METER("TCollection_DoubleMap operator=")
724 ////////////////////////////////aTOper.Stop();
725 PERF_STOP_METER("TCollection_DoubleMap operator=")
726 ////////////////////////////////aTClea.Start();
727 PERF_START_METER("TCollection_DoubleMap clearing")
729 ////////////////////////////////aTClea.Stop();
730 PERF_STOP_METER("TCollection_DoubleMap clearing")
732 printAllMeters(theDI);
733 if (iFail1 || iFail2)
734 std::cout << "Warning : N map failed " << iFail1 << " times, T map - " <<
738 // ===================== Test perform of IndexedMap type ==========================
739 static void CompIndexedMap (Draw_Interpretor& theDI,
740 const Standard_Integer theRep,
741 const Standard_Integer theSize)
743 Standard_Integer i,j;
745 ////////////////////////////////Perf_Meter aNBind ("NCollection_IndexedMap adding",0);
746 ////////////////////////////////Perf_Meter aTBind ("TCollection_IndexedMap adding",0);
747 ////////////////////////////////Perf_Meter aNOper ("NCollection_IndexedMap operator=",0);
748 ////////////////////////////////Perf_Meter aTOper ("TCollection_IndexedMap operator=",0);
749 ////////////////////////////////Perf_Meter aNFind ("NCollection_IndexedMap finding",0);
750 ////////////////////////////////Perf_Meter aTFind ("TCollection_IndexedMap finding",0);
751 ////////////////////////////////Perf_Meter aNClea ("NCollection_IndexedMap clearing",0);
752 ////////////////////////////////Perf_Meter aTClea ("TCollection_IndexedMap clearing",0);
753 ////////////////////////////////Perf_Meter aNAssi ("NCollection_IndexedMap Assign",0);
755 for (i=0; i<theRep; i++)
757 ////////////////////////////////QANCollection_IndexedMap a1, a2;
758 QANCollection_IndexedMapPerf a1, a2;
759 ////////////////////////////////aNBind.Start();
760 PERF_START_METER("NCollection_IndexedMap adding")
761 for (j=1; j<=theSize; j++)
767 ////////////////////////////////aNBind.Stop();
768 PERF_STOP_METER("NCollection_IndexedMap adding")
769 ////////////////////////////////aNFind.Start();
770 PERF_START_METER("NCollection_IndexedMap finding")
771 for (j=1; j<=theSize; j++)
777 ////////////////////////////////aNFind.Stop();
778 PERF_STOP_METER("NCollection_IndexedMap finding")
779 ////////////////////////////////aNOper.Start();
780 PERF_START_METER("NCollection_IndexedMap operator=")
782 ////////////////////////////////aNOper.Stop();
783 PERF_STOP_METER("NCollection_IndexedMap operator=")
784 ////////////////////////////////aNAssi.Start();
785 PERF_START_METER("NCollection_IndexedMap Assign")
787 ////////////////////////////////aNAssi.Stop();
788 PERF_STOP_METER("NCollection_IndexedMap Assign")
789 ////////////////////////////////aNClea.Start();
790 PERF_START_METER("NCollection_IndexedMap clearing")
792 ////////////////////////////////aNClea.Stop();
793 PERF_STOP_METER("NCollection_IndexedMap clearing")
796 for (i=0; i<theRep; i++)
798 TColStd_IndexedMapOfReal a1, a2;
799 ////////////////////////////////aTBind.Start();
800 PERF_START_METER("TCollection_IndexedMap adding")
801 for (j=1; j<=theSize; j++)
807 ////////////////////////////////aTBind.Stop();
808 PERF_STOP_METER("TCollection_IndexedMap adding")
809 ////////////////////////////////aTFind.Start();
810 PERF_START_METER("TCollection_IndexedMap finding")
811 for (j=1; j<=theSize; j++)
817 ////////////////////////////////aTFind.Stop();
818 PERF_STOP_METER("TCollection_IndexedMap finding")
819 ////////////////////////////////aTOper.Start();
820 PERF_START_METER("TCollection_IndexedMap operator=")
822 ////////////////////////////////aTOper.Stop();
823 PERF_STOP_METER("TCollection_IndexedMap operator=")
824 ////////////////////////////////aTClea.Start();
825 PERF_START_METER("TCollection_IndexedMap clearing")
827 ////////////////////////////////aTClea.Stop();
828 PERF_STOP_METER("TCollection_IndexedMap clearing")
830 printAllMeters(theDI);
833 // ===================== Test perform of IndexedDataMap type ==========================
834 static void CompIndexedDataMap (Draw_Interpretor& theDI,
835 const Standard_Integer theRep,
836 const Standard_Integer theSize)
838 Standard_Integer i,j;
840 ////////////////////////////////Perf_Meter aNBind ("NCollection_IndexedDataMap binding",0);
841 ////////////////////////////////Perf_Meter aTBind ("TCollection_IndexedDataMap binding",0);
842 ////////////////////////////////Perf_Meter aNFind ("NCollection_IndexedDataMap finding",0);
843 ////////////////////////////////Perf_Meter aTFind ("TCollection_IndexedDataMap finding",0);
844 ////////////////////////////////Perf_Meter aNOper ("NCollection_IndexedDataMap operator=",0);
845 ////////////////////////////////Perf_Meter aTOper ("TCollection_IndexedDataMap operator=",0);
846 ////////////////////////////////Perf_Meter aNClea ("NCollection_IndexedDataMap clearing",0);
847 ////////////////////////////////Perf_Meter aTClea ("TCollection_IndexedDataMap clearing",0);
848 //////////////////////////////////Perf_Meter aNAssi ("NCollection_IndexedDataMap Assign",0);
850 for (i=0; i<theRep; i++)
852 ////////////////////////////////QANCollection_IDMap a1, a2;
853 QANCollection_IDMapPerf a1, a2;
854 ////////////////////////////////aNBind.Start();
855 PERF_START_METER("NCollection_IndexedDataMap binding")
856 for (j=1; j<=theSize; j++)
862 a1.Add(aKey1,anItem);
864 ////////////////////////////////aNBind.Stop();
865 PERF_STOP_METER("NCollection_IndexedDataMap binding")
866 ////////////////////////////////aNFind.Start();
867 PERF_START_METER("NCollection_IndexedDataMap finding")
868 for (j=1; j<=theSize; j++)
874 ////////////////////////////////aNFind.Stop();
875 PERF_STOP_METER("NCollection_IndexedDataMap finding")
876 ////////////////////////////////aNOper.Start();
877 PERF_START_METER("NCollection_IndexedDataMap operator=")
879 ////////////////////////////////aNOper.Stop();
880 PERF_STOP_METER("NCollection_IndexedDataMap operator=")
884 ////////////////////////////////aNClea.Start();
885 PERF_START_METER("NCollection_IndexedDataMap clearing")
887 ////////////////////////////////aNClea.Stop();
888 PERF_STOP_METER("NCollection_IndexedDataMap clearing")
891 for (i=0; i<theRep; i++)
893 QANCollection_IndexedDataMapOfRealPnt a1, a2;
894 ////////////////////////////////aTBind.Start();
895 PERF_START_METER("TCollection_IndexedDataMap binding")
896 for (j=1; j<=theSize; j++)
902 a1.Add(aKey1,anItem);
904 ////////////////////////////////aTBind.Stop();
905 PERF_STOP_METER("TCollection_IndexedDataMap binding")
906 ////////////////////////////////aTFind.Start();
907 PERF_START_METER("TCollection_IndexedDataMap finding")
908 for (j=1; j<=theSize; j++)
914 ////////////////////////////////aTFind.Stop();
915 PERF_STOP_METER("TCollection_IndexedDataMap finding")
916 ////////////////////////////////aTOper.Start();
917 PERF_START_METER("TCollection_IndexedDataMap operator=")
919 ////////////////////////////////aTOper.Stop();
920 PERF_STOP_METER("TCollection_IndexedDataMap operator=")
921 ////////////////////////////////aTClea.Start();
922 PERF_START_METER("TCollection_IndexedDataMap clearing")
924 ////////////////////////////////aTClea.Stop();
925 PERF_STOP_METER("TCollection_IndexedDataMap clearing")
927 printAllMeters(theDI);
930 // ===================== Test perform of SparseArray type ==========================
931 static void CompSparseArray (Draw_Interpretor& theDI,
932 const Standard_Integer theRep,
933 const Standard_Integer theSize)
935 Standard_Integer i,j;
936 for (i=0; i<theRep; i++)
938 PERF_START_METER("NCollection_SparseArray creation")
940 NCollection_SparseArray<Standard_Integer> a1(theSize),a2(theSize);
942 PERF_STOP_METER("NCollection_SparseArray creation")
944 PERF_START_METER("NCollection_SparseArray filling")
945 for( j=0;j<theSize;j++ )
947 Standard_Integer iIndex;
948 Random(iIndex,theSize);
949 a1.SetValue(j,iIndex+1);
952 PERF_STOP_METER("NCollection_SparseArray filling")
954 PERF_START_METER("NCollection_SparseArray size")
955 Standard_Size sizeSparseArray=a1.Size();
956 (void)sizeSparseArray; // avoid compiler warning on unused variable
957 PERF_STOP_METER("NCollection_SparseArray size")
959 PERF_START_METER("NCollection_Array1 Assign")
961 PERF_STOP_METER("NCollection_Array1 Assign")
962 PERF_START_METER("NCollection_SparseArray HasValue")
963 for (j=0; j<theSize; j++)
965 Standard_Integer iIndex;
966 Random(iIndex,theSize);
967 a2.HasValue(iIndex+1);
969 PERF_STOP_METER("NCollection_SparseArray HasValue")
970 PERF_START_METER("NCollection_SparseArray UnsetValue")
971 for (j=0; j<theSize; j++)
973 Standard_Integer iIndex;
974 Random(iIndex,theSize);
975 a1.UnsetValue(iIndex+1);
977 PERF_STOP_METER("NCollection_SparseArray UnsetValue")
979 PERF_START_METER("NCollection_SparseArray Clear")
982 PERF_STOP_METER("NCollection_SparseArray Clear")
986 printAllMeters(theDI);
989 //=======================================================================
990 //function : CheckArguments
992 //=======================================================================
993 Standard_Integer CheckArguments(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& Repeat, Standard_Integer& Size)
996 di << "Usage : " << argv[0] << " Repeat Size\n";
999 Repeat = Draw::Atoi(argv[1]);
1000 Size = Draw::Atoi(argv[2]);
1002 di << "Repeat > 0\n";
1013 //=======================================================================
1014 //function : QANColPerfArray1
1016 //=======================================================================
1017 static Standard_Integer QANColPerfArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1019 Standard_Integer Repeat, Size;
1020 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1023 CompArray1 (di, Repeat, Size);
1027 //=======================================================================
1028 //function : QANColPerfArray2
1030 //=======================================================================
1031 static Standard_Integer QANColPerfArray2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1033 Standard_Integer Repeat, Size;
1034 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1037 CompArray2 (di, Repeat, Size);
1041 //=======================================================================
1042 //function : QANColPerfList
1044 //=======================================================================
1045 static Standard_Integer QANColPerfList(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1047 Standard_Integer Repeat, Size;
1048 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1051 CompList (di, Repeat, Size);
1055 //=======================================================================
1056 //function : QANColPerfSequence
1058 //=======================================================================
1059 static Standard_Integer QANColPerfSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1061 Standard_Integer Repeat, Size;
1062 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1065 CompSequence (di, Repeat, Size);
1069 //=======================================================================
1070 //function : QANColPerfMap
1072 //=======================================================================
1073 static Standard_Integer QANColPerfMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1075 Standard_Integer Repeat, Size;
1076 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1079 CompMap (di, Repeat, Size);
1083 //=======================================================================
1084 //function : QANColPerfDataMap
1086 //=======================================================================
1087 static Standard_Integer QANColPerfDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1089 Standard_Integer Repeat, Size;
1090 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1093 CompDataMap (di, Repeat, Size);
1097 //=======================================================================
1098 //function : QANColPerfDoubleMap
1100 //=======================================================================
1101 static Standard_Integer QANColPerfDoubleMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1103 Standard_Integer Repeat, Size;
1104 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1107 CompDoubleMap (di, Repeat, Size);
1111 //=======================================================================
1112 //function : QANColPerfIndexedMap
1114 //=======================================================================
1115 static Standard_Integer QANColPerfIndexedMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1117 Standard_Integer Repeat, Size;
1118 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1121 CompIndexedMap (di, Repeat, Size);
1125 //=======================================================================
1126 //function : QANColPerfIndexedDataMap
1128 //=======================================================================
1129 static Standard_Integer QANColPerfIndexedDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1131 Standard_Integer Repeat, Size;
1132 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1135 CompIndexedDataMap (di, Repeat, Size);
1139 //=======================================================================
1140 //function : QANColCheckSparseArray
1142 //=======================================================================
1143 static Standard_Integer QANColCheckSparseArray(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1145 Standard_Integer Repeat, Size;
1146 if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
1149 CompSparseArray (di, Repeat, Size);
1153 void QANCollection::CommandsPerf(Draw_Interpretor& theCommands) {
1154 const char *group = "QANCollection";
1156 // from agvCollTest/src/CollectionEXE/PerfTestEXE.cxx
1157 theCommands.Add("QANColPerfArray1", "QANColPerfArray1 Repeat Size", __FILE__, QANColPerfArray1, group);
1158 theCommands.Add("QANColPerfArray2", "QANColPerfArray2 Repeat Size", __FILE__, QANColPerfArray2, group);
1159 theCommands.Add("QANColPerfList", "QANColPerfList Repeat Size", __FILE__, QANColPerfList, group);
1160 theCommands.Add("QANColPerfSequence", "QANColPerfSequence Repeat Size", __FILE__, QANColPerfSequence, group);
1161 theCommands.Add("QANColPerfMap", "QANColPerfMap Repeat Size", __FILE__, QANColPerfMap, group);
1162 theCommands.Add("QANColPerfDataMap", "QANColPerfDataMap Repeat Size", __FILE__, QANColPerfDataMap, group);
1163 theCommands.Add("QANColPerfDoubleMap", "QANColPerfDoubleMap Repeat Size", __FILE__, QANColPerfDoubleMap, group);
1164 theCommands.Add("QANColPerfIndexedMap", "QANColPerfIndexedMap Repeat Size", __FILE__, QANColPerfIndexedMap, group);
1165 theCommands.Add("QANColPerfIndexedDataMap", "QANColPerfIndexedDataMap Repeat Size", __FILE__, QANColPerfIndexedDataMap, group);
1167 theCommands.Add("QANColCheckSparseArray", "QANColCheckSparseArray Repeat Size", __FILE__, QANColCheckSparseArray, group);