3a01a933 |
1 | // Created on: 2004-03-05 |
2 | // Created by: Mikhail KUZMITCHEV |
3 | // Copyright (c) 2004-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #include <QANCollection.hxx> |
17 | #include <QANCollection_Common.hxx> |
18 | |
19 | #include <Draw.hxx> |
20 | #include <Draw_Interpretor.hxx> |
21 | |
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> |
27 | |
28 | #include <QANCollection_DataMapOfRealPnt.hxx> |
29 | #include <QANCollection_DoubleMapOfRealInteger.hxx> |
30 | #include <QANCollection_IndexedDataMapOfRealPnt.hxx> |
31 | #include <QANCollection_ListOfPnt.hxx> |
32 | |
33 | #include <NCollection_SparseArray.hxx> |
34 | #include <NCollection_SparseArrayBase.hxx> |
35 | |
36 | #define PERF_ENABLE_METERS |
37 | #include <OSD_PerfMeter.hxx> |
38 | |
39 | #define ItemType gp_Pnt |
40 | #define Key1Type Standard_Real |
41 | #define Key2Type Standard_Integer |
42 | |
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 |
47 | |
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) |
54 | IMPLEMENT_HARRAY1(QANCollection_HArray1Perf) |
55 | |
56 | #include <NCollection_DefineArray2.hxx> |
57 | #include <NCollection_DefineHArray2.hxx> |
58 | ////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType) |
59 | ////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2) |
60 | DEFINE_ARRAY2(QANCollection_Array2Perf,QANCollection_BaseColPerf,ItemType) |
61 | DEFINE_HARRAY2(QANCollection_HArray2Perf,QANCollection_Array2Perf) |
62 | IMPLEMENT_HARRAY2(QANCollection_HArray2Perf) |
63 | |
64 | #include <NCollection_DefineMap.hxx> |
65 | #include <NCollection_DefineDataMap.hxx> |
66 | #include <NCollection_DefineDoubleMap.hxx> |
67 | #include <NCollection_DefineIndexedMap.hxx> |
68 | #include <NCollection_DefineIndexedDataMap.hxx> |
69 | ////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type) |
70 | ////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType) |
71 | ////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type) |
72 | ////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type) |
73 | ////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType) |
74 | DEFINE_MAP(QANCollection_MapPerf,QANCollection_Key1BaseColPerf,Key1Type) |
75 | DEFINE_DATAMAP(QANCollection_DataMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType) |
76 | DEFINE_DOUBLEMAP(QANCollection_DoubleMapPerf,QANCollection_Key2BaseColPerf,Key1Type,Key2Type) |
77 | DEFINE_INDEXEDMAP(QANCollection_IndexedMapPerf,QANCollection_Key1BaseColPerf,Key1Type) |
78 | DEFINE_INDEXEDDATAMAP(QANCollection_IDMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType) |
79 | |
80 | #include <NCollection_DefineList.hxx> |
81 | ////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType) |
82 | DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType) |
83 | |
84 | #include <NCollection_DefineSequence.hxx> |
85 | #include <NCollection_DefineHSequence.hxx> |
86 | ////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType) |
87 | ////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence) |
88 | DEFINE_SEQUENCE(QANCollection_SequencePerf,QANCollection_BaseColPerf,ItemType) |
89 | DEFINE_HSEQUENCE(QANCollection_HSequencePerf,QANCollection_SequencePerf) |
90 | IMPLEMENT_HSEQUENCE(QANCollection_HSequencePerf) |
91 | |
618617fe |
92 | static void printAllMeters (Draw_Interpretor& theDI) |
93 | { |
94 | char buffer[25600]; |
95 | perf_sprint_all_meters (buffer, 25600 - 1, 1); |
96 | theDI << buffer; |
97 | } |
98 | |
3a01a933 |
99 | // ===================== Test perform of Array1 type ========================== |
618617fe |
100 | static void CompArray1 (Draw_Interpretor& theDI, |
101 | const Standard_Integer theRep, |
3a01a933 |
102 | const Standard_Integer theSize) |
103 | { |
104 | Standard_Integer i,j; |
105 | |
106 | ////////////////////////////////Perf_Meter aNCrea ("NCollection_Array1 creation",0); |
107 | ////////////////////////////////Perf_Meter aTCrea ("TCollection_Array1 creation",0); |
108 | ////////////////////////////////Perf_Meter aNFill ("NCollection_Array1 filling",0); |
109 | ////////////////////////////////Perf_Meter aTFill ("TCollection_Array1 filling",0); |
110 | ////////////////////////////////Perf_Meter aNFind ("NCollection_Array1 finding",0); |
111 | ////////////////////////////////Perf_Meter aTFind ("TCollection_Array1 finding",0); |
112 | ////////////////////////////////Perf_Meter aNOper ("NCollection_Array1 operator=",0); |
113 | ////////////////////////////////Perf_Meter aTOper ("TCollection_Array1 operator=",0); |
114 | ////////////////////////////////Perf_Meter aNAssi ("NCollection_Array1 Assign",0); |
115 | for (i=0; i<theRep; i++) |
116 | { |
117 | ////////////////////////////////aNCrea.Start(); |
118 | PERF_START_METER("NCollection_Array1 creation") |
119 | ////////////////////////////////QANCollection_Array1 a1(1,theSize), a2(1,theSize); |
120 | QANCollection_Array1Perf a1(1,theSize), a2(1,theSize); |
121 | ////////////////////////////////aNCrea.Stop(); |
122 | PERF_STOP_METER("NCollection_Array1 creation") |
123 | ////////////////////////////////aNFill.Start(); |
124 | PERF_START_METER("NCollection_Array1 filling") |
125 | for (j=1; j<=theSize; j++) |
126 | Random(a1(j)); |
127 | ////////////////////////////////aNFill.Stop(); |
128 | PERF_STOP_METER("NCollection_Array1 filling") |
129 | ////////////////////////////////aNFind.Start(); |
130 | PERF_START_METER("NCollection_Array1 finding") |
131 | for (j=1; j<=theSize; j++) |
132 | { |
133 | Standard_Integer iIndex; |
134 | Random(iIndex,theSize); |
135 | a1.Value(iIndex+1); |
136 | } |
137 | ////////////////////////////////aNFind.Stop(); |
138 | PERF_STOP_METER("NCollection_Array1 finding") |
139 | ////////////////////////////////aNOper.Start(); |
140 | PERF_START_METER("NCollection_Array1 operator=") |
141 | a2 = a1; |
142 | ////////////////////////////////aNOper.Stop(); |
143 | PERF_STOP_METER("NCollection_Array1 operator=") |
144 | ////////////////////////////////aNAssi.Start(); |
145 | PERF_START_METER("NCollection_Array1 Assign") |
146 | a2.Assign(a1); |
147 | ////////////////////////////////aNAssi.Stop(); |
148 | PERF_STOP_METER("NCollection_Array1 Assign") |
149 | } |
150 | |
151 | for (i=0; i<theRep; i++) |
152 | { |
153 | ////////////////////////////////aTCrea.Start(); |
154 | PERF_START_METER("TCollection_Array1 creation") |
155 | TColgp_Array1OfPnt a1(1,theSize), a2(1,theSize); |
156 | ////////////////////////////////aTCrea.Stop(); |
157 | PERF_STOP_METER("TCollection_Array1 creation") |
158 | ////////////////////////////////aTFill.Start(); |
159 | PERF_START_METER("TCollection_Array1 filling") |
160 | for (j=1; j<=theSize; j++) |
161 | Random(a1(j)); |
162 | ////////////////////////////////aTFill.Stop(); |
163 | PERF_STOP_METER("TCollection_Array1 filling") |
164 | ////////////////////////////////aTFind.Start(); |
165 | PERF_START_METER("TCollection_Array1 finding") |
166 | for (j=1; j<=theSize; j++) |
167 | { |
168 | Standard_Integer iIndex; |
169 | Random(iIndex,theSize); |
170 | a1.Value(iIndex+1); |
171 | } |
172 | ////////////////////////////////aTFind.Stop(); |
173 | PERF_STOP_METER("TCollection_Array1 finding") |
174 | ////////////////////////////////aTOper.Start(); |
175 | PERF_START_METER("TCollection_Array1 operator=") |
176 | a2 = a1; |
177 | ////////////////////////////////aTOper.Stop(); |
178 | PERF_STOP_METER("TCollection_Array1 operator=") |
179 | } |
618617fe |
180 | printAllMeters(theDI); |
3a01a933 |
181 | } |
182 | |
183 | // ===================== Test perform of Array2 type ========================== |
618617fe |
184 | static void CompArray2 (Draw_Interpretor& theDI, |
185 | const Standard_Integer theRep, |
3a01a933 |
186 | const Standard_Integer theSize) |
187 | { |
188 | Standard_Integer i,j,k; |
189 | |
190 | ////////////////////////////////Perf_Meter aNCrea ("NCollection_Array2 creation",0); |
191 | ////////////////////////////////Perf_Meter aTCrea ("TCollection_Array2 creation",0); |
192 | ////////////////////////////////Perf_Meter aNFill ("NCollection_Array2 filling",0); |
193 | ////////////////////////////////Perf_Meter aTFill ("TCollection_Array2 filling",0); |
194 | ////////////////////////////////Perf_Meter aNFind ("NCollection_Array2 finding",0); |
195 | ////////////////////////////////Perf_Meter aTFind ("TCollection_Array2 finding",0); |
196 | ////////////////////////////////Perf_Meter aNOper ("NCollection_Array2 operator=",0); |
197 | ////////////////////////////////Perf_Meter aTOper ("TCollection_Array2 operator=",0); |
198 | ////////////////////////////////Perf_Meter aNAssi ("NCollection_Array2 Assign",0); |
199 | for (i=0; i<theRep; i++) |
200 | { |
201 | ////////////////////////////////aNCrea.Start(); |
202 | PERF_START_METER("NCollection_Array2 creation") |
203 | ////////////////////////////////QANCollection_Array2 a1(1,theSize,1,theSize), a2(1,theSize,1,theSize); |
204 | QANCollection_Array2Perf a1(1,theSize,1,theSize), a2(1,theSize,1,theSize); |
205 | ////////////////////////////////aNCrea.Stop(); |
206 | PERF_STOP_METER("NCollection_Array2 creation") |
207 | ////////////////////////////////aNFill.Start(); |
208 | PERF_START_METER("NCollection_Array2 filling") |
209 | for (j=1; j<=theSize; j++) |
210 | for (k=1; k<=theSize; k++) |
211 | Random(a1(j,k)); |
212 | ////////////////////////////////aNFill.Stop(); |
213 | PERF_STOP_METER("NCollection_Array2 filling") |
214 | ////////////////////////////////aNFind.Start(); |
215 | PERF_START_METER("NCollection_Array2 finding") |
216 | for (j=1; j<=theSize*theSize; j++) |
217 | { |
218 | Standard_Integer m,n; |
219 | Random(m,theSize); |
220 | Random(n,theSize); |
221 | a1.Value(m+1,n+1); |
222 | } |
223 | ////////////////////////////////aNFind.Stop(); |
224 | PERF_STOP_METER("NCollection_Array2 finding") |
225 | ////////////////////////////////aNOper.Start(); |
226 | PERF_START_METER("NCollection_Array2 operator=") |
227 | a2 = a1; |
228 | ////////////////////////////////aNOper.Stop(); |
229 | PERF_STOP_METER("NCollection_Array2 operator=") |
230 | ////////////////////////////////aNAssi.Start(); |
231 | PERF_START_METER("NCollection_Array2 Assign") |
232 | a2.Assign(a1); |
233 | ////////////////////////////////aNAssi.Stop(); |
234 | PERF_STOP_METER("NCollection_Array2 Assign") |
235 | } |
236 | |
237 | for (i=0; i<theRep; i++) |
238 | { |
239 | ////////////////////////////////aTCrea.Start(); |
240 | PERF_START_METER("TCollection_Array2 creation") |
241 | TColgp_Array2OfPnt a1(1,theSize,1,theSize), a2(1,theSize,1,theSize); |
242 | ////////////////////////////////aTCrea.Stop(); |
243 | PERF_STOP_METER("TCollection_Array2 creation") |
244 | ////////////////////////////////aTFill.Start(); |
245 | PERF_START_METER("TCollection_Array2 filling") |
246 | for (j=1; j<=theSize; j++) |
247 | for (k=1; k<=theSize; k++) |
248 | Random(a1(j,k)); |
249 | ////////////////////////////////aTFill.Stop(); |
250 | PERF_STOP_METER("TCollection_Array2 filling") |
251 | ////////////////////////////////aTFind.Start(); |
252 | PERF_START_METER("TCollection_Array2 finding") |
253 | for (j=1; j<=theSize*theSize; j++) |
254 | { |
255 | Standard_Integer m,n; |
256 | Random(m,theSize); |
257 | Random(n,theSize); |
258 | a1.Value(m+1,n+1); |
259 | } |
260 | ////////////////////////////////aTFind.Stop(); |
261 | PERF_STOP_METER("TCollection_Array2 finding") |
262 | ////////////////////////////////aTOper.Start(); |
263 | PERF_START_METER("TCollection_Array2 operator=") |
264 | a2 = a1; |
265 | ////////////////////////////////aTOper.Stop(); |
266 | PERF_STOP_METER("TCollection_Array2 operator=") |
267 | } |
618617fe |
268 | printAllMeters(theDI); |
3a01a933 |
269 | } |
270 | |
271 | // ===================== Test perform of List type ========================== |
618617fe |
272 | static void CompList (Draw_Interpretor& theDI, |
273 | const Standard_Integer theRep, |
3a01a933 |
274 | const Standard_Integer theSize) |
275 | { |
276 | Standard_Integer i,j; |
277 | |
278 | ////////////////////////////////Perf_Meter aNAppe ("NCollection_List appending",0); |
279 | ////////////////////////////////Perf_Meter aTAppe ("TCollection_List appending",0); |
280 | ////////////////////////////////Perf_Meter aNOper ("NCollection_List operator=",0); |
281 | ////////////////////////////////Perf_Meter aTOper ("TCollection_List operator=",0); |
282 | ////////////////////////////////Perf_Meter aNClea ("NCollection_List clearing",0); |
283 | ////////////////////////////////Perf_Meter aTClea ("TCollection_List clearing",0); |
284 | ////////////////////////////////Perf_Meter aNAssi ("NCollection_List Assign",0); |
285 | for (i=0; i<theRep; i++) |
286 | { |
287 | ////////////////////////////////QANCollection_List a1, a2; |
288 | QANCollection_ListPerf a1, a2; |
289 | ////////////////////////////////aNAppe.Start(); |
290 | PERF_START_METER("NCollection_List appending") |
291 | for (j=1; j<=theSize; j++) |
292 | { |
293 | ItemType anItem; |
294 | Random(anItem); |
295 | a1.Append(anItem); |
296 | } |
297 | ////////////////////////////////aNAppe.Stop(); |
298 | PERF_STOP_METER("NCollection_List appending") |
299 | ////////////////////////////////aNOper.Start(); |
300 | PERF_START_METER("NCollection_List operator=") |
301 | a2 = a1; |
302 | ////////////////////////////////aNOper.Stop(); |
303 | PERF_STOP_METER("NCollection_List operator=") |
304 | ////////////////////////////////aNAssi.Start(); |
305 | PERF_START_METER("NCollection_List Assign") |
306 | a2.Assign(a1); |
307 | ////////////////////////////////aNAssi.Stop(); |
308 | PERF_STOP_METER("NCollection_List Assign") |
309 | ////////////////////////////////aNClea.Start(); |
310 | PERF_START_METER("NCollection_List clearing") |
311 | a2.Clear(); |
312 | ////////////////////////////////aNClea.Stop(); |
313 | PERF_STOP_METER("NCollection_List clearing") |
314 | } |
315 | |
316 | for (i=0; i<theRep; i++) |
317 | { |
318 | QANCollection_ListOfPnt a1, a2; |
319 | ////////////////////////////////aTAppe.Start(); |
320 | PERF_START_METER("TCollection_List appending") |
321 | for (j=1; j<=theSize; j++) |
322 | { |
323 | ItemType anItem; |
324 | Random(anItem); |
325 | a1.Append(anItem); |
326 | } |
327 | ////////////////////////////////aTAppe.Stop(); |
328 | PERF_STOP_METER("TCollection_List appending") |
329 | ////////////////////////////////aTOper.Start(); |
330 | PERF_START_METER("TCollection_List operator=") |
331 | a2 = a1; |
332 | ////////////////////////////////aTOper.Stop(); |
333 | PERF_STOP_METER("TCollection_List operator=") |
334 | ////////////////////////////////aTClea.Start(); |
335 | PERF_START_METER("TCollection_List clearing") |
336 | a2.Clear(); |
337 | ////////////////////////////////aTClea.Stop(); |
338 | PERF_STOP_METER("TCollection_List clearing") |
339 | } |
618617fe |
340 | printAllMeters(theDI); |
3a01a933 |
341 | } |
342 | |
343 | // ===================== Test perform of Sequence type ========================== |
618617fe |
344 | static void CompSequence (Draw_Interpretor& theDI, |
345 | const Standard_Integer theRep, |
3a01a933 |
346 | const Standard_Integer theSize) |
347 | { |
348 | Standard_Integer i,j; |
349 | |
350 | ////////////////////////////////Perf_Meter aNAppe ("NCollection_Sequence appending",0); |
351 | ////////////////////////////////Perf_Meter aTAppe ("TCollection_Sequence appending",0); |
352 | ////////////////////////////////Perf_Meter aNFind ("NCollection_Sequence finding",0); |
353 | ////////////////////////////////Perf_Meter aTFind ("TCollection_Sequence finding",0); |
354 | ////////////////////////////////Perf_Meter aNOper ("NCollection_Sequence operator=",0); |
355 | ////////////////////////////////Perf_Meter aTOper ("TCollection_Sequence operator=",0); |
356 | ////////////////////////////////Perf_Meter aNClea ("NCollection_Sequence clearing",0); |
357 | ////////////////////////////////Perf_Meter aTClea ("TCollection_Sequence clearing",0); |
358 | ////////////////////////////////Perf_Meter aNAssi ("NCollection_Sequence Assign",0); |
359 | for (i=0; i<theRep; i++) |
360 | { |
361 | ////////////////////////////////QANCollection_Sequence a1, a2; |
362 | QANCollection_SequencePerf a1, a2; |
363 | ////////////////////////////////aNAppe.Start(); |
364 | PERF_START_METER("NCollection_Sequence appending") |
365 | for (j=1; j<=theSize; j++) |
366 | { |
367 | ItemType anItem; |
368 | Random(anItem); |
369 | a1.Append(anItem); |
370 | } |
371 | ////////////////////////////////aNAppe.Stop(); |
372 | PERF_STOP_METER("NCollection_Sequence appending") |
373 | ////////////////////////////////aNFind.Start(); |
374 | PERF_START_METER("NCollection_Sequence finding") |
375 | for (j=1; j<=theSize; j++) |
376 | { |
377 | Standard_Integer iIndex; |
378 | Random(iIndex,theSize); |
379 | a1.Value(iIndex+1); |
380 | } |
381 | ////////////////////////////////aNFind.Stop(); |
382 | PERF_STOP_METER("NCollection_Sequence finding") |
383 | ////////////////////////////////aNOper.Start(); |
384 | PERF_START_METER("NCollection_Sequence operator=") |
385 | a2 = a1; |
386 | ////////////////////////////////aNOper.Stop(); |
387 | PERF_STOP_METER("NCollection_Sequence operator=") |
388 | ////////////////////////////////aNAssi.Start(); |
389 | PERF_START_METER("NCollection_Sequence Assign") |
390 | a2.Assign(a1); |
391 | ////////////////////////////////aNAssi.Stop(); |
392 | PERF_STOP_METER("NCollection_Sequence Assign") |
393 | ////////////////////////////////aNClea.Start(); |
394 | PERF_START_METER("NCollection_Sequence clearing") |
395 | a2.Clear(); |
396 | ////////////////////////////////aNClea.Stop(); |
397 | PERF_STOP_METER("NCollection_Sequence clearing") |
398 | } |
399 | |
400 | for (i=0; i<theRep; i++) |
401 | { |
402 | TColgp_SequenceOfPnt a1, a2; |
403 | ////////////////////////////////aTAppe.Start(); |
404 | PERF_START_METER("TCollection_Sequence appending") |
405 | for (j=1; j<=theSize; j++) |
406 | { |
407 | ItemType anItem; |
408 | Random(anItem); |
409 | a1.Append(anItem); |
410 | } |
411 | ////////////////////////////////aTAppe.Stop(); |
412 | PERF_STOP_METER("TCollection_Sequence appending") |
413 | ////////////////////////////////aTFind.Start(); |
414 | PERF_START_METER("TCollection_Sequence finding") |
415 | for (j=1; j<=theSize; j++) |
416 | { |
417 | Standard_Integer iIndex; |
418 | Random(iIndex,theSize); |
419 | a1.Value(iIndex+1); |
420 | } |
421 | ////////////////////////////////aTFind.Stop(); |
422 | PERF_STOP_METER("TCollection_Sequence finding") |
423 | ////////////////////////////////aTOper.Start(); |
424 | PERF_START_METER("TCollection_Sequence operator=") |
425 | a2 = a1; |
426 | ////////////////////////////////aTOper.Stop(); |
427 | PERF_STOP_METER("TCollection_Sequence operator=") |
428 | ////////////////////////////////aTClea.Start(); |
429 | PERF_START_METER("TCollection_Sequence clearing") |
430 | a2.Clear(); |
431 | ////////////////////////////////aTClea.Stop(); |
432 | PERF_STOP_METER("TCollection_Sequence clearing") |
433 | } |
618617fe |
434 | printAllMeters(theDI); |
3a01a933 |
435 | } |
436 | |
437 | // ===================== Test perform of Map type ========================== |
618617fe |
438 | static void CompMap (Draw_Interpretor& theDI, |
439 | const Standard_Integer theRep, |
3a01a933 |
440 | const Standard_Integer theSize) |
441 | { |
442 | Standard_Integer i,j; |
443 | |
444 | ////////////////////////////////Perf_Meter aNBind ("NCollection_Map adding",0); |
445 | ////////////////////////////////Perf_Meter aTBind ("TCollection_Map adding",0); |
446 | ////////////////////////////////Perf_Meter aNOper ("NCollection_Map operator=",0); |
447 | ////////////////////////////////Perf_Meter aTOper ("TCollection_Map operator=",0); |
448 | ////////////////////////////////Perf_Meter aNFind ("NCollection_Map finding",0); |
449 | ////////////////////////////////Perf_Meter aTFind ("TCollection_Map finding",0); |
450 | ////////////////////////////////Perf_Meter aNClea ("NCollection_Map clearing",0); |
451 | ////////////////////////////////Perf_Meter aTClea ("TCollection_Map clearing",0); |
452 | ////////////////////////////////Perf_Meter aNAssi ("NCollection_Map Assign",0); |
453 | for (i=0; i<theRep; i++) |
454 | { |
455 | ////////////////////////////////QANCollection_Map a1, a2; |
456 | QANCollection_MapPerf a1, a2; |
457 | ////////////////////////////////aNBind.Start(); |
458 | PERF_START_METER("NCollection_Map adding") |
459 | for (j=1; j<=theSize; j++) |
460 | { |
461 | Key1Type aKey1; |
462 | Random(aKey1); |
463 | a1.Add(aKey1); |
464 | } |
465 | ////////////////////////////////aNBind.Stop(); |
466 | PERF_STOP_METER("NCollection_Map adding") |
467 | ////////////////////////////////aNFind.Start(); |
468 | PERF_START_METER("NCollection_Map finding") |
469 | for (j=1; j<=theSize; j++) |
470 | { |
471 | Key1Type aKey1; |
472 | Random(aKey1); |
473 | a1.Contains(aKey1); |
474 | } |
475 | ////////////////////////////////aNFind.Stop(); |
476 | PERF_STOP_METER("NCollection_Map finding") |
477 | ////////////////////////////////aNOper.Start(); |
478 | PERF_START_METER("NCollection_Map operator=") |
479 | a2 = a1; |
480 | ////////////////////////////////aNOper.Stop(); |
481 | PERF_STOP_METER("NCollection_Map operator=") |
482 | ////////////////////////////////aNAssi.Start(); |
483 | PERF_START_METER("NCollection_Map Assign") |
484 | a2.Assign(a1); |
485 | ////////////////////////////////aNAssi.Stop(); |
486 | PERF_STOP_METER("NCollection_Map Assign") |
487 | ////////////////////////////////aNClea.Start(); |
488 | PERF_START_METER("NCollection_Map clearing") |
489 | a2.Clear(); |
490 | ////////////////////////////////aNClea.Stop(); |
491 | PERF_STOP_METER("NCollection_Map clearing") |
492 | } |
493 | |
494 | for (i=0; i<theRep; i++) |
495 | { |
496 | TColStd_MapOfReal a1, a2; |
497 | ////////////////////////////////aTBind.Start(); |
498 | PERF_START_METER("TCollection_Map adding") |
499 | for (j=1; j<=theSize; j++) |
500 | { |
501 | Key1Type aKey1; |
502 | Random(aKey1); |
503 | a1.Add(aKey1); |
504 | } |
505 | ////////////////////////////////aTBind.Stop(); |
506 | PERF_STOP_METER("TCollection_Map adding") |
507 | ////////////////////////////////aTFind.Start(); |
508 | PERF_START_METER("TCollection_Map finding") |
509 | for (j=1; j<=theSize; j++) |
510 | { |
511 | Key1Type aKey1; |
512 | Random(aKey1); |
513 | a1.Contains(aKey1); |
514 | } |
515 | ////////////////////////////////aTFind.Stop(); |
516 | PERF_STOP_METER("TCollection_Map finding") |
517 | ////////////////////////////////aTOper.Start(); |
518 | PERF_START_METER("TCollection_Map operator=") |
519 | a2 = a1; |
520 | ////////////////////////////////aTOper.Stop(); |
521 | PERF_STOP_METER("TCollection_Map operator=") |
522 | ////////////////////////////////aTClea.Start(); |
523 | PERF_START_METER("TCollection_Map clearing") |
524 | a2.Clear(); |
525 | ////////////////////////////////aTClea.Stop(); |
526 | PERF_STOP_METER("TCollection_Map clearing") |
527 | } |
618617fe |
528 | printAllMeters(theDI); |
3a01a933 |
529 | } |
530 | |
531 | // ===================== Test perform of DataMap type ========================== |
618617fe |
532 | static void CompDataMap (Draw_Interpretor& theDI, |
533 | const Standard_Integer theRep, |
3a01a933 |
534 | const Standard_Integer theSize) |
535 | { |
536 | Standard_Integer i,j; |
537 | |
538 | ////////////////////////////////Perf_Meter aNBind ("NCollection_DataMap binding",0); |
539 | ////////////////////////////////Perf_Meter aTBind ("TCollection_DataMap binding",0); |
540 | ////////////////////////////////Perf_Meter aNFind ("NCollection_DataMap finding",0); |
541 | ////////////////////////////////Perf_Meter aTFind ("TCollection_DataMap finding",0); |
542 | ////////////////////////////////Perf_Meter aNOper ("NCollection_DataMap operator=",0); |
543 | ////////////////////////////////Perf_Meter aTOper ("TCollection_DataMap operator=",0); |
544 | ////////////////////////////////Perf_Meter aNClea ("NCollection_DataMap clearing",0); |
545 | ////////////////////////////////Perf_Meter aTClea ("TCollection_DataMap clearing",0); |
546 | //////////////////////////////////Perf_Meter aNAssi ("NCollection_DataMap Assign",0); |
547 | for (i=0; i<theRep; i++) |
548 | { |
549 | ////////////////////////////////QANCollection_DataMap a1, a2; |
550 | QANCollection_DataMapPerf a1, a2; |
551 | ////////////////////////////////aNBind.Start(); |
552 | PERF_START_METER("NCollection_DataMap binding") |
553 | for (j=1; j<=theSize; j++) |
554 | { |
555 | Key1Type aKey1; |
556 | ItemType anItem; |
557 | Random(aKey1); |
558 | Random(anItem); |
559 | a1.Bind(aKey1,anItem); |
560 | } |
561 | ////////////////////////////////aNBind.Stop(); |
562 | PERF_STOP_METER("NCollection_DataMap binding") |
563 | ////////////////////////////////aNFind.Start(); |
564 | PERF_START_METER("NCollection_DataMap finding") |
565 | for (j=1; j<=theSize; j++) |
566 | { |
567 | Key1Type aKey1; |
568 | Random(aKey1); |
569 | a1.IsBound(aKey1); |
570 | } |
571 | ////////////////////////////////aNFind.Stop(); |
572 | PERF_STOP_METER("NCollection_DataMap finding") |
573 | ////////////////////////////////aNOper.Start(); |
574 | PERF_START_METER("NCollection_DataMap operator=") |
575 | a2 = a1; |
576 | ////////////////////////////////aNOper.Stop(); |
577 | PERF_STOP_METER("NCollection_DataMap operator=") |
578 | //aNAssi.Start(); |
579 | //a2.Assign(a1); |
580 | //aNAssi.Stop(); |
581 | ////////////////////////////////aNClea.Start(); |
582 | PERF_START_METER("NCollection_DataMap clearing") |
583 | a2.Clear(); |
584 | ////////////////////////////////aNClea.Stop(); |
585 | PERF_STOP_METER("NCollection_DataMap clearing") |
586 | } |
587 | |
588 | for (i=0; i<theRep; i++) |
589 | { |
590 | QANCollection_DataMapOfRealPnt a1, a2; |
591 | ////////////////////////////////aTBind.Start(); |
592 | PERF_START_METER("TCollection_DataMap binding") |
593 | for (j=1; j<=theSize; j++) |
594 | { |
595 | Key1Type aKey1; |
596 | ItemType anItem; |
597 | Random(aKey1); |
598 | Random(anItem); |
599 | a1.Bind(aKey1,anItem); |
600 | } |
601 | ////////////////////////////////aTBind.Stop(); |
602 | PERF_STOP_METER("TCollection_DataMap binding") |
603 | ////////////////////////////////aTFind.Start(); |
604 | PERF_START_METER("TCollection_DataMap finding") |
605 | for (j=1; j<=theSize; j++) |
606 | { |
607 | Key1Type aKey1; |
608 | Random(aKey1); |
609 | a1.IsBound(aKey1); |
610 | } |
611 | ////////////////////////////////aTFind.Stop(); |
612 | PERF_STOP_METER("TCollection_DataMap finding") |
613 | ////////////////////////////////aTOper.Start(); |
614 | PERF_START_METER("TCollection_DataMap operator=") |
615 | a2 = a1; |
616 | ////////////////////////////////aTOper.Stop(); |
617 | PERF_STOP_METER("TCollection_DataMap operator=") |
618 | ////////////////////////////////aTClea.Start(); |
619 | PERF_START_METER("TCollection_DataMap clearing") |
620 | a2.Clear(); |
621 | ////////////////////////////////aTClea.Stop(); |
622 | PERF_STOP_METER("TCollection_DataMap clearing") |
623 | } |
618617fe |
624 | printAllMeters(theDI); |
3a01a933 |
625 | } |
626 | |
627 | // ===================== Test perform of DoubleMap type ========================== |
618617fe |
628 | static void CompDoubleMap (Draw_Interpretor& theDI, |
629 | const Standard_Integer theRep, |
3a01a933 |
630 | const Standard_Integer theSize) |
631 | { |
632 | Standard_Integer i,j; |
633 | Standard_Integer iFail1=0, iFail2=0; |
634 | |
635 | ////////////////////////////////Perf_Meter aNBind ("NCollection_DoubleMap binding",0); |
636 | ////////////////////////////////Perf_Meter aTBind ("TCollection_DoubleMap binding",0); |
637 | ////////////////////////////////Perf_Meter aNFind ("NCollection_DoubleMap finding",0); |
638 | ////////////////////////////////Perf_Meter aTFind ("TCollection_DoubleMap finding",0); |
639 | ////////////////////////////////Perf_Meter aNOper ("NCollection_DoubleMap operator=",0); |
640 | ////////////////////////////////Perf_Meter aTOper ("TCollection_DoubleMap operator=",0); |
641 | ////////////////////////////////Perf_Meter aNClea ("NCollection_DoubleMap clearing",0); |
642 | ////////////////////////////////Perf_Meter aTClea ("TCollection_DoubleMap clearing",0); |
643 | //////////////////////////////////Perf_Meter aNAssi ("NCollection_DoubleMap Assign",0); |
644 | for (i=0; i<theRep; i++) |
645 | { |
646 | ////////////////////////////////QANCollection_DoubleMap a1, a2; |
647 | QANCollection_DoubleMapPerf a1, a2; |
648 | ////////////////////////////////aNBind.Start(); |
649 | PERF_START_METER("NCollection_DoubleMap binding") |
650 | for (j=1; j<=theSize; j++) |
651 | { |
652 | Key1Type aKey1; |
653 | Key2Type aKey2; |
654 | do { |
655 | Random(aKey1); |
656 | Random(aKey2); |
657 | iFail1++; |
658 | } |
659 | while (a1.IsBound1(aKey1) || a1.IsBound2(aKey2)); |
660 | iFail1--; |
661 | a1.Bind(aKey1,aKey2); |
662 | } |
663 | ////////////////////////////////aNBind.Stop(); |
664 | PERF_STOP_METER("NCollection_DoubleMap binding") |
665 | ////////////////////////////////aNFind.Start(); |
666 | PERF_START_METER("NCollection_DoubleMap finding") |
667 | for (j=1; j<=theSize; j++) |
668 | { |
669 | Key1Type aKey1; |
670 | Key2Type aKey2; |
671 | Random(aKey1); |
672 | Random(aKey2); |
673 | a1.AreBound(aKey1,aKey2); |
674 | } |
675 | ////////////////////////////////aNFind.Stop(); |
676 | PERF_STOP_METER("NCollection_DoubleMap finding") |
677 | ////////////////////////////////aNOper.Start(); |
678 | PERF_START_METER("NCollection_DoubleMap operator=") |
679 | a2 = a1; |
680 | ////////////////////////////////aNOper.Stop(); |
681 | PERF_STOP_METER("NCollection_DoubleMap operator=") |
682 | //aNAssi.Start(); |
683 | //a2.Assign(a1); |
684 | //aNAssi.Stop(); |
685 | ////////////////////////////////aNClea.Start(); |
686 | PERF_START_METER("NCollection_DoubleMap clearing") |
687 | a2.Clear(); |
688 | ////////////////////////////////aNClea.Stop(); |
689 | PERF_STOP_METER("NCollection_DoubleMap clearing") |
690 | } |
691 | |
692 | for (i=0; i<theRep; i++) |
693 | { |
694 | QANCollection_DoubleMapOfRealInteger a1, a2; |
695 | ////////////////////////////////aTBind.Start(); |
696 | PERF_START_METER("TCollection_DoubleMap binding") |
697 | for (j=1; j<=theSize; j++) |
698 | { |
699 | Key1Type aKey1; |
700 | Key2Type aKey2; |
701 | do { |
702 | Random(aKey1); |
703 | Random(aKey2); |
704 | iFail2++; |
705 | } |
706 | while (a1.IsBound1(aKey1) || a1.IsBound2(aKey2)); |
707 | iFail2--; |
708 | a1.Bind(aKey1,aKey2); |
709 | } |
710 | ////////////////////////////////aTBind.Stop(); |
711 | PERF_STOP_METER("TCollection_DoubleMap binding") |
712 | ////////////////////////////////aTFind.Start(); |
713 | PERF_START_METER("TCollection_DoubleMap finding") |
714 | for (j=1; j<=theSize; j++) |
715 | { |
716 | Key1Type aKey1; |
717 | Key2Type aKey2; |
718 | Random(aKey1); |
719 | Random(aKey2); |
720 | a1.AreBound(aKey1,aKey2); |
721 | } |
722 | ////////////////////////////////aTFind.Stop(); |
723 | PERF_STOP_METER("TCollection_DoubleMap finding") |
724 | ////////////////////////////////aTOper.Start(); |
725 | PERF_START_METER("TCollection_DoubleMap operator=") |
726 | a2 = a1; |
727 | ////////////////////////////////aTOper.Stop(); |
728 | PERF_STOP_METER("TCollection_DoubleMap operator=") |
729 | ////////////////////////////////aTClea.Start(); |
730 | PERF_START_METER("TCollection_DoubleMap clearing") |
731 | a2.Clear(); |
732 | ////////////////////////////////aTClea.Stop(); |
733 | PERF_STOP_METER("TCollection_DoubleMap clearing") |
734 | } |
618617fe |
735 | printAllMeters(theDI); |
3a01a933 |
736 | if (iFail1 || iFail2) |
737 | cout << "Warning : N map failed " << iFail1 << " times, T map - " << |
738 | iFail2 << endl; |
739 | } |
740 | |
741 | // ===================== Test perform of IndexedMap type ========================== |
618617fe |
742 | static void CompIndexedMap (Draw_Interpretor& theDI, |
743 | const Standard_Integer theRep, |
3a01a933 |
744 | const Standard_Integer theSize) |
745 | { |
746 | Standard_Integer i,j; |
747 | |
748 | ////////////////////////////////Perf_Meter aNBind ("NCollection_IndexedMap adding",0); |
749 | ////////////////////////////////Perf_Meter aTBind ("TCollection_IndexedMap adding",0); |
750 | ////////////////////////////////Perf_Meter aNOper ("NCollection_IndexedMap operator=",0); |
751 | ////////////////////////////////Perf_Meter aTOper ("TCollection_IndexedMap operator=",0); |
752 | ////////////////////////////////Perf_Meter aNFind ("NCollection_IndexedMap finding",0); |
753 | ////////////////////////////////Perf_Meter aTFind ("TCollection_IndexedMap finding",0); |
754 | ////////////////////////////////Perf_Meter aNClea ("NCollection_IndexedMap clearing",0); |
755 | ////////////////////////////////Perf_Meter aTClea ("TCollection_IndexedMap clearing",0); |
756 | ////////////////////////////////Perf_Meter aNAssi ("NCollection_IndexedMap Assign",0); |
757 | |
758 | for (i=0; i<theRep; i++) |
759 | { |
760 | ////////////////////////////////QANCollection_IndexedMap a1, a2; |
761 | QANCollection_IndexedMapPerf a1, a2; |
762 | ////////////////////////////////aNBind.Start(); |
763 | PERF_START_METER("NCollection_IndexedMap adding") |
764 | for (j=1; j<=theSize; j++) |
765 | { |
766 | Key1Type aKey1; |
767 | Random(aKey1); |
768 | a1.Add(aKey1); |
769 | } |
770 | ////////////////////////////////aNBind.Stop(); |
771 | PERF_STOP_METER("NCollection_IndexedMap adding") |
772 | ////////////////////////////////aNFind.Start(); |
773 | PERF_START_METER("NCollection_IndexedMap finding") |
774 | for (j=1; j<=theSize; j++) |
775 | { |
776 | Key1Type aKey1; |
777 | Random(aKey1); |
778 | a1.Contains(aKey1); |
779 | } |
780 | ////////////////////////////////aNFind.Stop(); |
781 | PERF_STOP_METER("NCollection_IndexedMap finding") |
782 | ////////////////////////////////aNOper.Start(); |
783 | PERF_START_METER("NCollection_IndexedMap operator=") |
784 | a2 = a1; |
785 | ////////////////////////////////aNOper.Stop(); |
786 | PERF_STOP_METER("NCollection_IndexedMap operator=") |
787 | ////////////////////////////////aNAssi.Start(); |
788 | PERF_START_METER("NCollection_IndexedMap Assign") |
789 | a2.Assign(a1); |
790 | ////////////////////////////////aNAssi.Stop(); |
791 | PERF_STOP_METER("NCollection_IndexedMap Assign") |
792 | ////////////////////////////////aNClea.Start(); |
793 | PERF_START_METER("NCollection_IndexedMap clearing") |
794 | a2.Clear(); |
795 | ////////////////////////////////aNClea.Stop(); |
796 | PERF_STOP_METER("NCollection_IndexedMap clearing") |
797 | } |
798 | |
799 | for (i=0; i<theRep; i++) |
800 | { |
801 | TColStd_IndexedMapOfReal a1, a2; |
802 | ////////////////////////////////aTBind.Start(); |
803 | PERF_START_METER("TCollection_IndexedMap adding") |
804 | for (j=1; j<=theSize; j++) |
805 | { |
806 | Key1Type aKey1; |
807 | Random(aKey1); |
808 | a1.Add(aKey1); |
809 | } |
810 | ////////////////////////////////aTBind.Stop(); |
811 | PERF_STOP_METER("TCollection_IndexedMap adding") |
812 | ////////////////////////////////aTFind.Start(); |
813 | PERF_START_METER("TCollection_IndexedMap finding") |
814 | for (j=1; j<=theSize; j++) |
815 | { |
816 | Key1Type aKey1; |
817 | Random(aKey1); |
818 | a1.Contains(aKey1); |
819 | } |
820 | ////////////////////////////////aTFind.Stop(); |
821 | PERF_STOP_METER("TCollection_IndexedMap finding") |
822 | ////////////////////////////////aTOper.Start(); |
823 | PERF_START_METER("TCollection_IndexedMap operator=") |
824 | a2 = a1; |
825 | ////////////////////////////////aTOper.Stop(); |
826 | PERF_STOP_METER("TCollection_IndexedMap operator=") |
827 | ////////////////////////////////aTClea.Start(); |
828 | PERF_START_METER("TCollection_IndexedMap clearing") |
829 | a2.Clear(); |
830 | ////////////////////////////////aTClea.Stop(); |
831 | PERF_STOP_METER("TCollection_IndexedMap clearing") |
832 | } |
618617fe |
833 | printAllMeters(theDI); |
3a01a933 |
834 | } |
835 | |
836 | // ===================== Test perform of IndexedDataMap type ========================== |
618617fe |
837 | static void CompIndexedDataMap (Draw_Interpretor& theDI, |
838 | const Standard_Integer theRep, |
3a01a933 |
839 | const Standard_Integer theSize) |
840 | { |
841 | Standard_Integer i,j; |
842 | |
843 | ////////////////////////////////Perf_Meter aNBind ("NCollection_IndexedDataMap binding",0); |
844 | ////////////////////////////////Perf_Meter aTBind ("TCollection_IndexedDataMap binding",0); |
845 | ////////////////////////////////Perf_Meter aNFind ("NCollection_IndexedDataMap finding",0); |
846 | ////////////////////////////////Perf_Meter aTFind ("TCollection_IndexedDataMap finding",0); |
847 | ////////////////////////////////Perf_Meter aNOper ("NCollection_IndexedDataMap operator=",0); |
848 | ////////////////////////////////Perf_Meter aTOper ("TCollection_IndexedDataMap operator=",0); |
849 | ////////////////////////////////Perf_Meter aNClea ("NCollection_IndexedDataMap clearing",0); |
850 | ////////////////////////////////Perf_Meter aTClea ("TCollection_IndexedDataMap clearing",0); |
851 | //////////////////////////////////Perf_Meter aNAssi ("NCollection_IndexedDataMap Assign",0); |
852 | |
853 | for (i=0; i<theRep; i++) |
854 | { |
855 | ////////////////////////////////QANCollection_IDMap a1, a2; |
856 | QANCollection_IDMapPerf a1, a2; |
857 | ////////////////////////////////aNBind.Start(); |
858 | PERF_START_METER("NCollection_IndexedDataMap binding") |
859 | for (j=1; j<=theSize; j++) |
860 | { |
861 | Key1Type aKey1; |
862 | ItemType anItem; |
863 | Random(aKey1); |
864 | Random(anItem); |
865 | a1.Add(aKey1,anItem); |
866 | } |
867 | ////////////////////////////////aNBind.Stop(); |
868 | PERF_STOP_METER("NCollection_IndexedDataMap binding") |
869 | ////////////////////////////////aNFind.Start(); |
870 | PERF_START_METER("NCollection_IndexedDataMap finding") |
871 | for (j=1; j<=theSize; j++) |
872 | { |
873 | Key1Type aKey1; |
874 | Random(aKey1); |
875 | a1.Contains(aKey1); |
876 | } |
877 | ////////////////////////////////aNFind.Stop(); |
878 | PERF_STOP_METER("NCollection_IndexedDataMap finding") |
879 | ////////////////////////////////aNOper.Start(); |
880 | PERF_START_METER("NCollection_IndexedDataMap operator=") |
881 | a2 = a1; |
882 | ////////////////////////////////aNOper.Stop(); |
883 | PERF_STOP_METER("NCollection_IndexedDataMap operator=") |
884 | //aNAssi.Start(); |
885 | //a2.Assign(a1); |
886 | //aNAssi.Stop(); |
887 | ////////////////////////////////aNClea.Start(); |
888 | PERF_START_METER("NCollection_IndexedDataMap clearing") |
889 | a2.Clear(); |
890 | ////////////////////////////////aNClea.Stop(); |
891 | PERF_STOP_METER("NCollection_IndexedDataMap clearing") |
892 | } |
893 | |
894 | for (i=0; i<theRep; i++) |
895 | { |
896 | QANCollection_IndexedDataMapOfRealPnt a1, a2; |
897 | ////////////////////////////////aTBind.Start(); |
898 | PERF_START_METER("TCollection_IndexedDataMap binding") |
899 | for (j=1; j<=theSize; j++) |
900 | { |
901 | Key1Type aKey1; |
902 | ItemType anItem; |
903 | Random(aKey1); |
904 | Random(anItem); |
905 | a1.Add(aKey1,anItem); |
906 | } |
907 | ////////////////////////////////aTBind.Stop(); |
908 | PERF_STOP_METER("TCollection_IndexedDataMap binding") |
909 | ////////////////////////////////aTFind.Start(); |
910 | PERF_START_METER("TCollection_IndexedDataMap finding") |
911 | for (j=1; j<=theSize; j++) |
912 | { |
913 | Key1Type aKey1; |
914 | Random(aKey1); |
915 | a1.Contains(aKey1); |
916 | } |
917 | ////////////////////////////////aTFind.Stop(); |
918 | PERF_STOP_METER("TCollection_IndexedDataMap finding") |
919 | ////////////////////////////////aTOper.Start(); |
920 | PERF_START_METER("TCollection_IndexedDataMap operator=") |
921 | a2 = a1; |
922 | ////////////////////////////////aTOper.Stop(); |
923 | PERF_STOP_METER("TCollection_IndexedDataMap operator=") |
924 | ////////////////////////////////aTClea.Start(); |
925 | PERF_START_METER("TCollection_IndexedDataMap clearing") |
926 | a2.Clear(); |
927 | ////////////////////////////////aTClea.Stop(); |
928 | PERF_STOP_METER("TCollection_IndexedDataMap clearing") |
929 | } |
618617fe |
930 | printAllMeters(theDI); |
3a01a933 |
931 | } |
932 | |
933 | // ===================== Test perform of SparseArray type ========================== |
618617fe |
934 | static void CompSparseArray (Draw_Interpretor& theDI, |
935 | const Standard_Integer theRep, |
936 | const Standard_Integer theSize) |
3a01a933 |
937 | { |
938 | Standard_Integer i,j; |
939 | for (i=0; i<theRep; i++) |
940 | { |
941 | PERF_START_METER("NCollection_SparseArray creation") |
942 | |
943 | NCollection_SparseArray<Standard_Integer> a1(theSize),a2(theSize); |
944 | |
945 | PERF_STOP_METER("NCollection_SparseArray creation") |
946 | |
947 | PERF_START_METER("NCollection_SparseArray filling") |
948 | for( j=0;j<theSize;j++ ) |
949 | { |
950 | Standard_Integer iIndex; |
951 | Random(iIndex,theSize); |
952 | a1.SetValue(j,iIndex+1); |
953 | } |
954 | |
955 | PERF_STOP_METER("NCollection_SparseArray filling") |
956 | |
957 | PERF_START_METER("NCollection_SparseArray size") |
958 | Standard_Size sizeSparseArray=a1.Size(); |
959 | (void)sizeSparseArray; // avoid compiler warning on unused variable |
960 | PERF_STOP_METER("NCollection_SparseArray size") |
961 | |
962 | PERF_START_METER("NCollection_Array1 Assign") |
963 | a2.Assign(a1); |
964 | PERF_STOP_METER("NCollection_Array1 Assign") |
965 | PERF_START_METER("NCollection_SparseArray HasValue") |
966 | for (j=0; j<theSize; j++) |
967 | { |
968 | Standard_Integer iIndex; |
969 | Random(iIndex,theSize); |
970 | a2.HasValue(iIndex+1); |
971 | } |
972 | PERF_STOP_METER("NCollection_SparseArray HasValue") |
973 | PERF_START_METER("NCollection_SparseArray UnsetValue") |
974 | for (j=0; j<theSize; j++) |
975 | { |
976 | Standard_Integer iIndex; |
977 | Random(iIndex,theSize); |
978 | a1.UnsetValue(iIndex+1); |
979 | } |
980 | PERF_STOP_METER("NCollection_SparseArray UnsetValue") |
981 | |
982 | PERF_START_METER("NCollection_SparseArray Clear") |
983 | a1.Clear(); |
984 | a2.Clear(); |
985 | PERF_STOP_METER("NCollection_SparseArray Clear") |
986 | |
987 | } |
988 | |
618617fe |
989 | printAllMeters(theDI); |
3a01a933 |
990 | } |
991 | |
992 | //======================================================================= |
993 | //function : CheckArguments |
994 | //purpose : |
995 | //======================================================================= |
996 | Standard_Integer CheckArguments(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& Repeat, Standard_Integer& Size) |
997 | { |
998 | if ( argc != 3) { |
999 | di << "Usage : " << argv[0] << " Repeat Size" << "\n"; |
1000 | return 1; |
1001 | } |
1002 | Repeat = Draw::Atoi(argv[1]); |
1003 | Size = Draw::Atoi(argv[2]); |
1004 | if ( Repeat < 1 ) { |
1005 | di << "Repeat > 0" << "\n"; |
1006 | return 1; |
1007 | } |
1008 | if ( Size < 1 ) { |
1009 | di << "Size > 0" << "\n"; |
1010 | return 1; |
1011 | } |
1012 | return 0; |
1013 | } |
1014 | |
1015 | |
1016 | //======================================================================= |
1017 | //function : QANColPerfArray1 |
1018 | //purpose : |
1019 | //======================================================================= |
1020 | static Standard_Integer QANColPerfArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1021 | { |
1022 | Standard_Integer Repeat, Size; |
1023 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1024 | return 1; |
1025 | } |
618617fe |
1026 | CompArray1 (di, Repeat, Size); |
3a01a933 |
1027 | return 0; |
1028 | } |
1029 | |
1030 | //======================================================================= |
1031 | //function : QANColPerfArray2 |
1032 | //purpose : |
1033 | //======================================================================= |
1034 | static Standard_Integer QANColPerfArray2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1035 | { |
1036 | Standard_Integer Repeat, Size; |
1037 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1038 | return 1; |
1039 | } |
618617fe |
1040 | CompArray2 (di, Repeat, Size); |
3a01a933 |
1041 | return 0; |
1042 | } |
1043 | |
1044 | //======================================================================= |
1045 | //function : QANColPerfList |
1046 | //purpose : |
1047 | //======================================================================= |
1048 | static Standard_Integer QANColPerfList(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1049 | { |
1050 | Standard_Integer Repeat, Size; |
1051 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1052 | return 1; |
1053 | } |
618617fe |
1054 | CompList (di, Repeat, Size); |
3a01a933 |
1055 | return 0; |
1056 | } |
1057 | |
1058 | //======================================================================= |
1059 | //function : QANColPerfSequence |
1060 | //purpose : |
1061 | //======================================================================= |
1062 | static Standard_Integer QANColPerfSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1063 | { |
1064 | Standard_Integer Repeat, Size; |
1065 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1066 | return 1; |
1067 | } |
618617fe |
1068 | CompSequence (di, Repeat, Size); |
3a01a933 |
1069 | return 0; |
1070 | } |
1071 | |
1072 | //======================================================================= |
1073 | //function : QANColPerfMap |
1074 | //purpose : |
1075 | //======================================================================= |
1076 | static Standard_Integer QANColPerfMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1077 | { |
1078 | Standard_Integer Repeat, Size; |
1079 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1080 | return 1; |
1081 | } |
618617fe |
1082 | CompMap (di, Repeat, Size); |
3a01a933 |
1083 | return 0; |
1084 | } |
1085 | |
1086 | //======================================================================= |
1087 | //function : QANColPerfDataMap |
1088 | //purpose : |
1089 | //======================================================================= |
1090 | static Standard_Integer QANColPerfDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1091 | { |
1092 | Standard_Integer Repeat, Size; |
1093 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1094 | return 1; |
1095 | } |
618617fe |
1096 | CompDataMap (di, Repeat, Size); |
3a01a933 |
1097 | return 0; |
1098 | } |
1099 | |
1100 | //======================================================================= |
1101 | //function : QANColPerfDoubleMap |
1102 | //purpose : |
1103 | //======================================================================= |
1104 | static Standard_Integer QANColPerfDoubleMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1105 | { |
1106 | Standard_Integer Repeat, Size; |
1107 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1108 | return 1; |
1109 | } |
618617fe |
1110 | CompDoubleMap (di, Repeat, Size); |
3a01a933 |
1111 | return 0; |
1112 | } |
1113 | |
1114 | //======================================================================= |
1115 | //function : QANColPerfIndexedMap |
1116 | //purpose : |
1117 | //======================================================================= |
1118 | static Standard_Integer QANColPerfIndexedMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1119 | { |
1120 | Standard_Integer Repeat, Size; |
1121 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1122 | return 1; |
1123 | } |
618617fe |
1124 | CompIndexedMap (di, Repeat, Size); |
3a01a933 |
1125 | return 0; |
1126 | } |
1127 | |
1128 | //======================================================================= |
1129 | //function : QANColPerfIndexedDataMap |
1130 | //purpose : |
1131 | //======================================================================= |
1132 | static Standard_Integer QANColPerfIndexedDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1133 | { |
1134 | Standard_Integer Repeat, Size; |
1135 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1136 | return 1; |
1137 | } |
618617fe |
1138 | CompIndexedDataMap (di, Repeat, Size); |
3a01a933 |
1139 | return 0; |
1140 | } |
1141 | |
1142 | //======================================================================= |
1143 | //function : QANColCheckSparseArray |
1144 | //purpose : |
1145 | //======================================================================= |
1146 | static Standard_Integer QANColCheckSparseArray(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1147 | { |
1148 | Standard_Integer Repeat, Size; |
1149 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1150 | return 1; |
1151 | } |
618617fe |
1152 | CompSparseArray (di, Repeat, Size); |
3a01a933 |
1153 | return 0; |
1154 | } |
1155 | |
1156 | void QANCollection::CommandsPerf(Draw_Interpretor& theCommands) { |
1157 | const char *group = "QANCollection"; |
1158 | |
1159 | // from agvCollTest/src/CollectionEXE/PerfTestEXE.cxx |
1160 | theCommands.Add("QANColPerfArray1", "QANColPerfArray1 Repeat Size", __FILE__, QANColPerfArray1, group); |
1161 | theCommands.Add("QANColPerfArray2", "QANColPerfArray2 Repeat Size", __FILE__, QANColPerfArray2, group); |
1162 | theCommands.Add("QANColPerfList", "QANColPerfList Repeat Size", __FILE__, QANColPerfList, group); |
1163 | theCommands.Add("QANColPerfSequence", "QANColPerfSequence Repeat Size", __FILE__, QANColPerfSequence, group); |
1164 | theCommands.Add("QANColPerfMap", "QANColPerfMap Repeat Size", __FILE__, QANColPerfMap, group); |
1165 | theCommands.Add("QANColPerfDataMap", "QANColPerfDataMap Repeat Size", __FILE__, QANColPerfDataMap, group); |
1166 | theCommands.Add("QANColPerfDoubleMap", "QANColPerfDoubleMap Repeat Size", __FILE__, QANColPerfDoubleMap, group); |
1167 | theCommands.Add("QANColPerfIndexedMap", "QANColPerfIndexedMap Repeat Size", __FILE__, QANColPerfIndexedMap, group); |
1168 | theCommands.Add("QANColPerfIndexedDataMap", "QANColPerfIndexedDataMap Repeat Size", __FILE__, QANColPerfIndexedDataMap, group); |
1169 | |
1170 | theCommands.Add("QANColCheckSparseArray", "QANColCheckSparseArray Repeat Size", __FILE__, QANColCheckSparseArray, group); |
1171 | |
1172 | return; |
1173 | } |
1174 | |