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) |
3a01a933 |
54 | |
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) |
3a01a933 |
61 | |
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) |
77 | |
78 | #include <NCollection_DefineList.hxx> |
79 | ////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType) |
80 | DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType) |
81 | |
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) |
3a01a933 |
88 | |
618617fe |
89 | static void printAllMeters (Draw_Interpretor& theDI) |
90 | { |
91 | char buffer[25600]; |
92 | perf_sprint_all_meters (buffer, 25600 - 1, 1); |
93 | theDI << buffer; |
94 | } |
95 | |
3a01a933 |
96 | // ===================== Test perform of Array1 type ========================== |
618617fe |
97 | static void CompArray1 (Draw_Interpretor& theDI, |
98 | const Standard_Integer theRep, |
3a01a933 |
99 | const Standard_Integer theSize) |
100 | { |
101 | Standard_Integer i,j; |
102 | |
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++) |
113 | { |
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++) |
123 | Random(a1(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++) |
129 | { |
130 | Standard_Integer iIndex; |
131 | Random(iIndex,theSize); |
132 | a1.Value(iIndex+1); |
133 | } |
134 | ////////////////////////////////aNFind.Stop(); |
135 | PERF_STOP_METER("NCollection_Array1 finding") |
136 | ////////////////////////////////aNOper.Start(); |
137 | PERF_START_METER("NCollection_Array1 operator=") |
138 | a2 = a1; |
139 | ////////////////////////////////aNOper.Stop(); |
140 | PERF_STOP_METER("NCollection_Array1 operator=") |
141 | ////////////////////////////////aNAssi.Start(); |
142 | PERF_START_METER("NCollection_Array1 Assign") |
143 | a2.Assign(a1); |
144 | ////////////////////////////////aNAssi.Stop(); |
145 | PERF_STOP_METER("NCollection_Array1 Assign") |
146 | } |
147 | |
148 | for (i=0; i<theRep; i++) |
149 | { |
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++) |
158 | Random(a1(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++) |
164 | { |
165 | Standard_Integer iIndex; |
166 | Random(iIndex,theSize); |
167 | a1.Value(iIndex+1); |
168 | } |
169 | ////////////////////////////////aTFind.Stop(); |
170 | PERF_STOP_METER("TCollection_Array1 finding") |
171 | ////////////////////////////////aTOper.Start(); |
172 | PERF_START_METER("TCollection_Array1 operator=") |
173 | a2 = a1; |
174 | ////////////////////////////////aTOper.Stop(); |
175 | PERF_STOP_METER("TCollection_Array1 operator=") |
176 | } |
618617fe |
177 | printAllMeters(theDI); |
3a01a933 |
178 | } |
179 | |
180 | // ===================== Test perform of Array2 type ========================== |
618617fe |
181 | static void CompArray2 (Draw_Interpretor& theDI, |
182 | const Standard_Integer theRep, |
3a01a933 |
183 | const Standard_Integer theSize) |
184 | { |
185 | Standard_Integer i,j,k; |
186 | |
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++) |
197 | { |
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++) |
208 | Random(a1(j,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++) |
214 | { |
215 | Standard_Integer m,n; |
216 | Random(m,theSize); |
217 | Random(n,theSize); |
218 | a1.Value(m+1,n+1); |
219 | } |
220 | ////////////////////////////////aNFind.Stop(); |
221 | PERF_STOP_METER("NCollection_Array2 finding") |
222 | ////////////////////////////////aNOper.Start(); |
223 | PERF_START_METER("NCollection_Array2 operator=") |
224 | a2 = a1; |
225 | ////////////////////////////////aNOper.Stop(); |
226 | PERF_STOP_METER("NCollection_Array2 operator=") |
227 | ////////////////////////////////aNAssi.Start(); |
228 | PERF_START_METER("NCollection_Array2 Assign") |
229 | a2.Assign(a1); |
230 | ////////////////////////////////aNAssi.Stop(); |
231 | PERF_STOP_METER("NCollection_Array2 Assign") |
232 | } |
233 | |
234 | for (i=0; i<theRep; i++) |
235 | { |
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++) |
245 | Random(a1(j,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++) |
251 | { |
252 | Standard_Integer m,n; |
253 | Random(m,theSize); |
254 | Random(n,theSize); |
255 | a1.Value(m+1,n+1); |
256 | } |
257 | ////////////////////////////////aTFind.Stop(); |
258 | PERF_STOP_METER("TCollection_Array2 finding") |
259 | ////////////////////////////////aTOper.Start(); |
260 | PERF_START_METER("TCollection_Array2 operator=") |
261 | a2 = a1; |
262 | ////////////////////////////////aTOper.Stop(); |
263 | PERF_STOP_METER("TCollection_Array2 operator=") |
264 | } |
618617fe |
265 | printAllMeters(theDI); |
3a01a933 |
266 | } |
267 | |
268 | // ===================== Test perform of List type ========================== |
618617fe |
269 | static void CompList (Draw_Interpretor& theDI, |
270 | const Standard_Integer theRep, |
3a01a933 |
271 | const Standard_Integer theSize) |
272 | { |
273 | Standard_Integer i,j; |
274 | |
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++) |
283 | { |
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++) |
289 | { |
290 | ItemType anItem; |
291 | Random(anItem); |
292 | a1.Append(anItem); |
293 | } |
294 | ////////////////////////////////aNAppe.Stop(); |
295 | PERF_STOP_METER("NCollection_List appending") |
296 | ////////////////////////////////aNOper.Start(); |
297 | PERF_START_METER("NCollection_List operator=") |
298 | a2 = a1; |
299 | ////////////////////////////////aNOper.Stop(); |
300 | PERF_STOP_METER("NCollection_List operator=") |
301 | ////////////////////////////////aNAssi.Start(); |
302 | PERF_START_METER("NCollection_List Assign") |
303 | a2.Assign(a1); |
304 | ////////////////////////////////aNAssi.Stop(); |
305 | PERF_STOP_METER("NCollection_List Assign") |
306 | ////////////////////////////////aNClea.Start(); |
307 | PERF_START_METER("NCollection_List clearing") |
308 | a2.Clear(); |
309 | ////////////////////////////////aNClea.Stop(); |
310 | PERF_STOP_METER("NCollection_List clearing") |
311 | } |
312 | |
313 | for (i=0; i<theRep; i++) |
314 | { |
315 | QANCollection_ListOfPnt a1, a2; |
316 | ////////////////////////////////aTAppe.Start(); |
317 | PERF_START_METER("TCollection_List appending") |
318 | for (j=1; j<=theSize; j++) |
319 | { |
320 | ItemType anItem; |
321 | Random(anItem); |
322 | a1.Append(anItem); |
323 | } |
324 | ////////////////////////////////aTAppe.Stop(); |
325 | PERF_STOP_METER("TCollection_List appending") |
326 | ////////////////////////////////aTOper.Start(); |
327 | PERF_START_METER("TCollection_List operator=") |
328 | a2 = a1; |
329 | ////////////////////////////////aTOper.Stop(); |
330 | PERF_STOP_METER("TCollection_List operator=") |
331 | ////////////////////////////////aTClea.Start(); |
332 | PERF_START_METER("TCollection_List clearing") |
333 | a2.Clear(); |
334 | ////////////////////////////////aTClea.Stop(); |
335 | PERF_STOP_METER("TCollection_List clearing") |
336 | } |
618617fe |
337 | printAllMeters(theDI); |
3a01a933 |
338 | } |
339 | |
340 | // ===================== Test perform of Sequence type ========================== |
618617fe |
341 | static void CompSequence (Draw_Interpretor& theDI, |
342 | const Standard_Integer theRep, |
3a01a933 |
343 | const Standard_Integer theSize) |
344 | { |
345 | Standard_Integer i,j; |
346 | |
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++) |
357 | { |
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++) |
363 | { |
364 | ItemType anItem; |
365 | Random(anItem); |
366 | a1.Append(anItem); |
367 | } |
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++) |
373 | { |
374 | Standard_Integer iIndex; |
375 | Random(iIndex,theSize); |
376 | a1.Value(iIndex+1); |
377 | } |
378 | ////////////////////////////////aNFind.Stop(); |
379 | PERF_STOP_METER("NCollection_Sequence finding") |
380 | ////////////////////////////////aNOper.Start(); |
381 | PERF_START_METER("NCollection_Sequence operator=") |
382 | a2 = a1; |
383 | ////////////////////////////////aNOper.Stop(); |
384 | PERF_STOP_METER("NCollection_Sequence operator=") |
385 | ////////////////////////////////aNAssi.Start(); |
386 | PERF_START_METER("NCollection_Sequence Assign") |
387 | a2.Assign(a1); |
388 | ////////////////////////////////aNAssi.Stop(); |
389 | PERF_STOP_METER("NCollection_Sequence Assign") |
390 | ////////////////////////////////aNClea.Start(); |
391 | PERF_START_METER("NCollection_Sequence clearing") |
392 | a2.Clear(); |
393 | ////////////////////////////////aNClea.Stop(); |
394 | PERF_STOP_METER("NCollection_Sequence clearing") |
395 | } |
396 | |
397 | for (i=0; i<theRep; i++) |
398 | { |
399 | TColgp_SequenceOfPnt a1, a2; |
400 | ////////////////////////////////aTAppe.Start(); |
401 | PERF_START_METER("TCollection_Sequence appending") |
402 | for (j=1; j<=theSize; j++) |
403 | { |
404 | ItemType anItem; |
405 | Random(anItem); |
406 | a1.Append(anItem); |
407 | } |
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++) |
413 | { |
414 | Standard_Integer iIndex; |
415 | Random(iIndex,theSize); |
416 | a1.Value(iIndex+1); |
417 | } |
418 | ////////////////////////////////aTFind.Stop(); |
419 | PERF_STOP_METER("TCollection_Sequence finding") |
420 | ////////////////////////////////aTOper.Start(); |
421 | PERF_START_METER("TCollection_Sequence operator=") |
422 | a2 = a1; |
423 | ////////////////////////////////aTOper.Stop(); |
424 | PERF_STOP_METER("TCollection_Sequence operator=") |
425 | ////////////////////////////////aTClea.Start(); |
426 | PERF_START_METER("TCollection_Sequence clearing") |
427 | a2.Clear(); |
428 | ////////////////////////////////aTClea.Stop(); |
429 | PERF_STOP_METER("TCollection_Sequence clearing") |
430 | } |
618617fe |
431 | printAllMeters(theDI); |
3a01a933 |
432 | } |
433 | |
434 | // ===================== Test perform of Map type ========================== |
618617fe |
435 | static void CompMap (Draw_Interpretor& theDI, |
436 | const Standard_Integer theRep, |
3a01a933 |
437 | const Standard_Integer theSize) |
438 | { |
439 | Standard_Integer i,j; |
440 | |
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++) |
451 | { |
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++) |
457 | { |
458 | Key1Type aKey1; |
459 | Random(aKey1); |
460 | a1.Add(aKey1); |
461 | } |
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++) |
467 | { |
468 | Key1Type aKey1; |
469 | Random(aKey1); |
470 | a1.Contains(aKey1); |
471 | } |
472 | ////////////////////////////////aNFind.Stop(); |
473 | PERF_STOP_METER("NCollection_Map finding") |
474 | ////////////////////////////////aNOper.Start(); |
475 | PERF_START_METER("NCollection_Map operator=") |
476 | a2 = a1; |
477 | ////////////////////////////////aNOper.Stop(); |
478 | PERF_STOP_METER("NCollection_Map operator=") |
479 | ////////////////////////////////aNAssi.Start(); |
480 | PERF_START_METER("NCollection_Map Assign") |
481 | a2.Assign(a1); |
482 | ////////////////////////////////aNAssi.Stop(); |
483 | PERF_STOP_METER("NCollection_Map Assign") |
484 | ////////////////////////////////aNClea.Start(); |
485 | PERF_START_METER("NCollection_Map clearing") |
486 | a2.Clear(); |
487 | ////////////////////////////////aNClea.Stop(); |
488 | PERF_STOP_METER("NCollection_Map clearing") |
489 | } |
490 | |
491 | for (i=0; i<theRep; i++) |
492 | { |
493 | TColStd_MapOfReal a1, a2; |
494 | ////////////////////////////////aTBind.Start(); |
495 | PERF_START_METER("TCollection_Map adding") |
496 | for (j=1; j<=theSize; j++) |
497 | { |
498 | Key1Type aKey1; |
499 | Random(aKey1); |
500 | a1.Add(aKey1); |
501 | } |
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++) |
507 | { |
508 | Key1Type aKey1; |
509 | Random(aKey1); |
510 | a1.Contains(aKey1); |
511 | } |
512 | ////////////////////////////////aTFind.Stop(); |
513 | PERF_STOP_METER("TCollection_Map finding") |
514 | ////////////////////////////////aTOper.Start(); |
515 | PERF_START_METER("TCollection_Map operator=") |
516 | a2 = a1; |
517 | ////////////////////////////////aTOper.Stop(); |
518 | PERF_STOP_METER("TCollection_Map operator=") |
519 | ////////////////////////////////aTClea.Start(); |
520 | PERF_START_METER("TCollection_Map clearing") |
521 | a2.Clear(); |
522 | ////////////////////////////////aTClea.Stop(); |
523 | PERF_STOP_METER("TCollection_Map clearing") |
524 | } |
618617fe |
525 | printAllMeters(theDI); |
3a01a933 |
526 | } |
527 | |
528 | // ===================== Test perform of DataMap type ========================== |
618617fe |
529 | static void CompDataMap (Draw_Interpretor& theDI, |
530 | const Standard_Integer theRep, |
3a01a933 |
531 | const Standard_Integer theSize) |
532 | { |
533 | Standard_Integer i,j; |
534 | |
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++) |
545 | { |
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++) |
551 | { |
552 | Key1Type aKey1; |
553 | ItemType anItem; |
554 | Random(aKey1); |
555 | Random(anItem); |
556 | a1.Bind(aKey1,anItem); |
557 | } |
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++) |
563 | { |
564 | Key1Type aKey1; |
565 | Random(aKey1); |
566 | a1.IsBound(aKey1); |
567 | } |
568 | ////////////////////////////////aNFind.Stop(); |
569 | PERF_STOP_METER("NCollection_DataMap finding") |
570 | ////////////////////////////////aNOper.Start(); |
571 | PERF_START_METER("NCollection_DataMap operator=") |
572 | a2 = a1; |
573 | ////////////////////////////////aNOper.Stop(); |
574 | PERF_STOP_METER("NCollection_DataMap operator=") |
575 | //aNAssi.Start(); |
576 | //a2.Assign(a1); |
577 | //aNAssi.Stop(); |
578 | ////////////////////////////////aNClea.Start(); |
579 | PERF_START_METER("NCollection_DataMap clearing") |
580 | a2.Clear(); |
581 | ////////////////////////////////aNClea.Stop(); |
582 | PERF_STOP_METER("NCollection_DataMap clearing") |
583 | } |
584 | |
585 | for (i=0; i<theRep; i++) |
586 | { |
587 | QANCollection_DataMapOfRealPnt a1, a2; |
588 | ////////////////////////////////aTBind.Start(); |
589 | PERF_START_METER("TCollection_DataMap binding") |
590 | for (j=1; j<=theSize; j++) |
591 | { |
592 | Key1Type aKey1; |
593 | ItemType anItem; |
594 | Random(aKey1); |
595 | Random(anItem); |
596 | a1.Bind(aKey1,anItem); |
597 | } |
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++) |
603 | { |
604 | Key1Type aKey1; |
605 | Random(aKey1); |
606 | a1.IsBound(aKey1); |
607 | } |
608 | ////////////////////////////////aTFind.Stop(); |
609 | PERF_STOP_METER("TCollection_DataMap finding") |
610 | ////////////////////////////////aTOper.Start(); |
611 | PERF_START_METER("TCollection_DataMap operator=") |
612 | a2 = a1; |
613 | ////////////////////////////////aTOper.Stop(); |
614 | PERF_STOP_METER("TCollection_DataMap operator=") |
615 | ////////////////////////////////aTClea.Start(); |
616 | PERF_START_METER("TCollection_DataMap clearing") |
617 | a2.Clear(); |
618 | ////////////////////////////////aTClea.Stop(); |
619 | PERF_STOP_METER("TCollection_DataMap clearing") |
620 | } |
618617fe |
621 | printAllMeters(theDI); |
3a01a933 |
622 | } |
623 | |
624 | // ===================== Test perform of DoubleMap type ========================== |
618617fe |
625 | static void CompDoubleMap (Draw_Interpretor& theDI, |
626 | const Standard_Integer theRep, |
3a01a933 |
627 | const Standard_Integer theSize) |
628 | { |
629 | Standard_Integer i,j; |
630 | Standard_Integer iFail1=0, iFail2=0; |
631 | |
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++) |
642 | { |
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++) |
648 | { |
649 | Key1Type aKey1; |
650 | Key2Type aKey2; |
651 | do { |
652 | Random(aKey1); |
653 | Random(aKey2); |
654 | iFail1++; |
655 | } |
656 | while (a1.IsBound1(aKey1) || a1.IsBound2(aKey2)); |
657 | iFail1--; |
658 | a1.Bind(aKey1,aKey2); |
659 | } |
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++) |
665 | { |
666 | Key1Type aKey1; |
667 | Key2Type aKey2; |
668 | Random(aKey1); |
669 | Random(aKey2); |
670 | a1.AreBound(aKey1,aKey2); |
671 | } |
672 | ////////////////////////////////aNFind.Stop(); |
673 | PERF_STOP_METER("NCollection_DoubleMap finding") |
674 | ////////////////////////////////aNOper.Start(); |
675 | PERF_START_METER("NCollection_DoubleMap operator=") |
676 | a2 = a1; |
677 | ////////////////////////////////aNOper.Stop(); |
678 | PERF_STOP_METER("NCollection_DoubleMap operator=") |
679 | //aNAssi.Start(); |
680 | //a2.Assign(a1); |
681 | //aNAssi.Stop(); |
682 | ////////////////////////////////aNClea.Start(); |
683 | PERF_START_METER("NCollection_DoubleMap clearing") |
684 | a2.Clear(); |
685 | ////////////////////////////////aNClea.Stop(); |
686 | PERF_STOP_METER("NCollection_DoubleMap clearing") |
687 | } |
688 | |
689 | for (i=0; i<theRep; i++) |
690 | { |
691 | QANCollection_DoubleMapOfRealInteger a1, a2; |
692 | ////////////////////////////////aTBind.Start(); |
693 | PERF_START_METER("TCollection_DoubleMap binding") |
694 | for (j=1; j<=theSize; j++) |
695 | { |
696 | Key1Type aKey1; |
697 | Key2Type aKey2; |
698 | do { |
699 | Random(aKey1); |
700 | Random(aKey2); |
701 | iFail2++; |
702 | } |
703 | while (a1.IsBound1(aKey1) || a1.IsBound2(aKey2)); |
704 | iFail2--; |
705 | a1.Bind(aKey1,aKey2); |
706 | } |
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++) |
712 | { |
713 | Key1Type aKey1; |
714 | Key2Type aKey2; |
715 | Random(aKey1); |
716 | Random(aKey2); |
717 | a1.AreBound(aKey1,aKey2); |
718 | } |
719 | ////////////////////////////////aTFind.Stop(); |
720 | PERF_STOP_METER("TCollection_DoubleMap finding") |
721 | ////////////////////////////////aTOper.Start(); |
722 | PERF_START_METER("TCollection_DoubleMap operator=") |
723 | a2 = a1; |
724 | ////////////////////////////////aTOper.Stop(); |
725 | PERF_STOP_METER("TCollection_DoubleMap operator=") |
726 | ////////////////////////////////aTClea.Start(); |
727 | PERF_START_METER("TCollection_DoubleMap clearing") |
728 | a2.Clear(); |
729 | ////////////////////////////////aTClea.Stop(); |
730 | PERF_STOP_METER("TCollection_DoubleMap clearing") |
731 | } |
618617fe |
732 | printAllMeters(theDI); |
3a01a933 |
733 | if (iFail1 || iFail2) |
04232180 |
734 | std::cout << "Warning : N map failed " << iFail1 << " times, T map - " << |
735 | iFail2 << std::endl; |
3a01a933 |
736 | } |
737 | |
738 | // ===================== Test perform of IndexedMap type ========================== |
618617fe |
739 | static void CompIndexedMap (Draw_Interpretor& theDI, |
740 | const Standard_Integer theRep, |
3a01a933 |
741 | const Standard_Integer theSize) |
742 | { |
743 | Standard_Integer i,j; |
744 | |
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); |
754 | |
755 | for (i=0; i<theRep; i++) |
756 | { |
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++) |
762 | { |
763 | Key1Type aKey1; |
764 | Random(aKey1); |
765 | a1.Add(aKey1); |
766 | } |
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++) |
772 | { |
773 | Key1Type aKey1; |
774 | Random(aKey1); |
775 | a1.Contains(aKey1); |
776 | } |
777 | ////////////////////////////////aNFind.Stop(); |
778 | PERF_STOP_METER("NCollection_IndexedMap finding") |
779 | ////////////////////////////////aNOper.Start(); |
780 | PERF_START_METER("NCollection_IndexedMap operator=") |
781 | a2 = a1; |
782 | ////////////////////////////////aNOper.Stop(); |
783 | PERF_STOP_METER("NCollection_IndexedMap operator=") |
784 | ////////////////////////////////aNAssi.Start(); |
785 | PERF_START_METER("NCollection_IndexedMap Assign") |
786 | a2.Assign(a1); |
787 | ////////////////////////////////aNAssi.Stop(); |
788 | PERF_STOP_METER("NCollection_IndexedMap Assign") |
789 | ////////////////////////////////aNClea.Start(); |
790 | PERF_START_METER("NCollection_IndexedMap clearing") |
791 | a2.Clear(); |
792 | ////////////////////////////////aNClea.Stop(); |
793 | PERF_STOP_METER("NCollection_IndexedMap clearing") |
794 | } |
795 | |
796 | for (i=0; i<theRep; i++) |
797 | { |
798 | TColStd_IndexedMapOfReal a1, a2; |
799 | ////////////////////////////////aTBind.Start(); |
800 | PERF_START_METER("TCollection_IndexedMap adding") |
801 | for (j=1; j<=theSize; j++) |
802 | { |
803 | Key1Type aKey1; |
804 | Random(aKey1); |
805 | a1.Add(aKey1); |
806 | } |
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++) |
812 | { |
813 | Key1Type aKey1; |
814 | Random(aKey1); |
815 | a1.Contains(aKey1); |
816 | } |
817 | ////////////////////////////////aTFind.Stop(); |
818 | PERF_STOP_METER("TCollection_IndexedMap finding") |
819 | ////////////////////////////////aTOper.Start(); |
820 | PERF_START_METER("TCollection_IndexedMap operator=") |
821 | a2 = a1; |
822 | ////////////////////////////////aTOper.Stop(); |
823 | PERF_STOP_METER("TCollection_IndexedMap operator=") |
824 | ////////////////////////////////aTClea.Start(); |
825 | PERF_START_METER("TCollection_IndexedMap clearing") |
826 | a2.Clear(); |
827 | ////////////////////////////////aTClea.Stop(); |
828 | PERF_STOP_METER("TCollection_IndexedMap clearing") |
829 | } |
618617fe |
830 | printAllMeters(theDI); |
3a01a933 |
831 | } |
832 | |
833 | // ===================== Test perform of IndexedDataMap type ========================== |
618617fe |
834 | static void CompIndexedDataMap (Draw_Interpretor& theDI, |
835 | const Standard_Integer theRep, |
3a01a933 |
836 | const Standard_Integer theSize) |
837 | { |
838 | Standard_Integer i,j; |
839 | |
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); |
849 | |
850 | for (i=0; i<theRep; i++) |
851 | { |
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++) |
857 | { |
858 | Key1Type aKey1; |
859 | ItemType anItem; |
860 | Random(aKey1); |
861 | Random(anItem); |
862 | a1.Add(aKey1,anItem); |
863 | } |
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++) |
869 | { |
870 | Key1Type aKey1; |
871 | Random(aKey1); |
872 | a1.Contains(aKey1); |
873 | } |
874 | ////////////////////////////////aNFind.Stop(); |
875 | PERF_STOP_METER("NCollection_IndexedDataMap finding") |
876 | ////////////////////////////////aNOper.Start(); |
877 | PERF_START_METER("NCollection_IndexedDataMap operator=") |
878 | a2 = a1; |
879 | ////////////////////////////////aNOper.Stop(); |
880 | PERF_STOP_METER("NCollection_IndexedDataMap operator=") |
881 | //aNAssi.Start(); |
882 | //a2.Assign(a1); |
883 | //aNAssi.Stop(); |
884 | ////////////////////////////////aNClea.Start(); |
885 | PERF_START_METER("NCollection_IndexedDataMap clearing") |
886 | a2.Clear(); |
887 | ////////////////////////////////aNClea.Stop(); |
888 | PERF_STOP_METER("NCollection_IndexedDataMap clearing") |
889 | } |
890 | |
891 | for (i=0; i<theRep; i++) |
892 | { |
893 | QANCollection_IndexedDataMapOfRealPnt a1, a2; |
894 | ////////////////////////////////aTBind.Start(); |
895 | PERF_START_METER("TCollection_IndexedDataMap binding") |
896 | for (j=1; j<=theSize; j++) |
897 | { |
898 | Key1Type aKey1; |
899 | ItemType anItem; |
900 | Random(aKey1); |
901 | Random(anItem); |
902 | a1.Add(aKey1,anItem); |
903 | } |
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++) |
909 | { |
910 | Key1Type aKey1; |
911 | Random(aKey1); |
912 | a1.Contains(aKey1); |
913 | } |
914 | ////////////////////////////////aTFind.Stop(); |
915 | PERF_STOP_METER("TCollection_IndexedDataMap finding") |
916 | ////////////////////////////////aTOper.Start(); |
917 | PERF_START_METER("TCollection_IndexedDataMap operator=") |
918 | a2 = a1; |
919 | ////////////////////////////////aTOper.Stop(); |
920 | PERF_STOP_METER("TCollection_IndexedDataMap operator=") |
921 | ////////////////////////////////aTClea.Start(); |
922 | PERF_START_METER("TCollection_IndexedDataMap clearing") |
923 | a2.Clear(); |
924 | ////////////////////////////////aTClea.Stop(); |
925 | PERF_STOP_METER("TCollection_IndexedDataMap clearing") |
926 | } |
618617fe |
927 | printAllMeters(theDI); |
3a01a933 |
928 | } |
929 | |
930 | // ===================== Test perform of SparseArray type ========================== |
618617fe |
931 | static void CompSparseArray (Draw_Interpretor& theDI, |
932 | const Standard_Integer theRep, |
933 | const Standard_Integer theSize) |
3a01a933 |
934 | { |
935 | Standard_Integer i,j; |
936 | for (i=0; i<theRep; i++) |
937 | { |
938 | PERF_START_METER("NCollection_SparseArray creation") |
939 | |
940 | NCollection_SparseArray<Standard_Integer> a1(theSize),a2(theSize); |
941 | |
942 | PERF_STOP_METER("NCollection_SparseArray creation") |
943 | |
944 | PERF_START_METER("NCollection_SparseArray filling") |
945 | for( j=0;j<theSize;j++ ) |
946 | { |
947 | Standard_Integer iIndex; |
948 | Random(iIndex,theSize); |
949 | a1.SetValue(j,iIndex+1); |
950 | } |
951 | |
952 | PERF_STOP_METER("NCollection_SparseArray filling") |
953 | |
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") |
958 | |
959 | PERF_START_METER("NCollection_Array1 Assign") |
960 | a2.Assign(a1); |
961 | PERF_STOP_METER("NCollection_Array1 Assign") |
962 | PERF_START_METER("NCollection_SparseArray HasValue") |
963 | for (j=0; j<theSize; j++) |
964 | { |
965 | Standard_Integer iIndex; |
966 | Random(iIndex,theSize); |
967 | a2.HasValue(iIndex+1); |
968 | } |
969 | PERF_STOP_METER("NCollection_SparseArray HasValue") |
970 | PERF_START_METER("NCollection_SparseArray UnsetValue") |
971 | for (j=0; j<theSize; j++) |
972 | { |
973 | Standard_Integer iIndex; |
974 | Random(iIndex,theSize); |
975 | a1.UnsetValue(iIndex+1); |
976 | } |
977 | PERF_STOP_METER("NCollection_SparseArray UnsetValue") |
978 | |
979 | PERF_START_METER("NCollection_SparseArray Clear") |
980 | a1.Clear(); |
981 | a2.Clear(); |
982 | PERF_STOP_METER("NCollection_SparseArray Clear") |
983 | |
984 | } |
985 | |
618617fe |
986 | printAllMeters(theDI); |
3a01a933 |
987 | } |
988 | |
989 | //======================================================================= |
990 | //function : CheckArguments |
991 | //purpose : |
992 | //======================================================================= |
993 | Standard_Integer CheckArguments(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& Repeat, Standard_Integer& Size) |
994 | { |
995 | if ( argc != 3) { |
586db386 |
996 | di << "Usage : " << argv[0] << " Repeat Size\n"; |
3a01a933 |
997 | return 1; |
998 | } |
999 | Repeat = Draw::Atoi(argv[1]); |
1000 | Size = Draw::Atoi(argv[2]); |
1001 | if ( Repeat < 1 ) { |
586db386 |
1002 | di << "Repeat > 0\n"; |
3a01a933 |
1003 | return 1; |
1004 | } |
1005 | if ( Size < 1 ) { |
586db386 |
1006 | di << "Size > 0\n"; |
3a01a933 |
1007 | return 1; |
1008 | } |
1009 | return 0; |
1010 | } |
1011 | |
1012 | |
1013 | //======================================================================= |
1014 | //function : QANColPerfArray1 |
1015 | //purpose : |
1016 | //======================================================================= |
1017 | static Standard_Integer QANColPerfArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1018 | { |
1019 | Standard_Integer Repeat, Size; |
1020 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1021 | return 1; |
1022 | } |
618617fe |
1023 | CompArray1 (di, Repeat, Size); |
3a01a933 |
1024 | return 0; |
1025 | } |
1026 | |
1027 | //======================================================================= |
1028 | //function : QANColPerfArray2 |
1029 | //purpose : |
1030 | //======================================================================= |
1031 | static Standard_Integer QANColPerfArray2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1032 | { |
1033 | Standard_Integer Repeat, Size; |
1034 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1035 | return 1; |
1036 | } |
618617fe |
1037 | CompArray2 (di, Repeat, Size); |
3a01a933 |
1038 | return 0; |
1039 | } |
1040 | |
1041 | //======================================================================= |
1042 | //function : QANColPerfList |
1043 | //purpose : |
1044 | //======================================================================= |
1045 | static Standard_Integer QANColPerfList(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1046 | { |
1047 | Standard_Integer Repeat, Size; |
1048 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1049 | return 1; |
1050 | } |
618617fe |
1051 | CompList (di, Repeat, Size); |
3a01a933 |
1052 | return 0; |
1053 | } |
1054 | |
1055 | //======================================================================= |
1056 | //function : QANColPerfSequence |
1057 | //purpose : |
1058 | //======================================================================= |
1059 | static Standard_Integer QANColPerfSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1060 | { |
1061 | Standard_Integer Repeat, Size; |
1062 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1063 | return 1; |
1064 | } |
618617fe |
1065 | CompSequence (di, Repeat, Size); |
3a01a933 |
1066 | return 0; |
1067 | } |
1068 | |
1069 | //======================================================================= |
1070 | //function : QANColPerfMap |
1071 | //purpose : |
1072 | //======================================================================= |
1073 | static Standard_Integer QANColPerfMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1074 | { |
1075 | Standard_Integer Repeat, Size; |
1076 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1077 | return 1; |
1078 | } |
618617fe |
1079 | CompMap (di, Repeat, Size); |
3a01a933 |
1080 | return 0; |
1081 | } |
1082 | |
1083 | //======================================================================= |
1084 | //function : QANColPerfDataMap |
1085 | //purpose : |
1086 | //======================================================================= |
1087 | static Standard_Integer QANColPerfDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1088 | { |
1089 | Standard_Integer Repeat, Size; |
1090 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1091 | return 1; |
1092 | } |
618617fe |
1093 | CompDataMap (di, Repeat, Size); |
3a01a933 |
1094 | return 0; |
1095 | } |
1096 | |
1097 | //======================================================================= |
1098 | //function : QANColPerfDoubleMap |
1099 | //purpose : |
1100 | //======================================================================= |
1101 | static Standard_Integer QANColPerfDoubleMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1102 | { |
1103 | Standard_Integer Repeat, Size; |
1104 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1105 | return 1; |
1106 | } |
618617fe |
1107 | CompDoubleMap (di, Repeat, Size); |
3a01a933 |
1108 | return 0; |
1109 | } |
1110 | |
1111 | //======================================================================= |
1112 | //function : QANColPerfIndexedMap |
1113 | //purpose : |
1114 | //======================================================================= |
1115 | static Standard_Integer QANColPerfIndexedMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1116 | { |
1117 | Standard_Integer Repeat, Size; |
1118 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1119 | return 1; |
1120 | } |
618617fe |
1121 | CompIndexedMap (di, Repeat, Size); |
3a01a933 |
1122 | return 0; |
1123 | } |
1124 | |
1125 | //======================================================================= |
1126 | //function : QANColPerfIndexedDataMap |
1127 | //purpose : |
1128 | //======================================================================= |
1129 | static Standard_Integer QANColPerfIndexedDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1130 | { |
1131 | Standard_Integer Repeat, Size; |
1132 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1133 | return 1; |
1134 | } |
618617fe |
1135 | CompIndexedDataMap (di, Repeat, Size); |
3a01a933 |
1136 | return 0; |
1137 | } |
1138 | |
1139 | //======================================================================= |
1140 | //function : QANColCheckSparseArray |
1141 | //purpose : |
1142 | //======================================================================= |
1143 | static Standard_Integer QANColCheckSparseArray(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
1144 | { |
1145 | Standard_Integer Repeat, Size; |
1146 | if ( CheckArguments(di, argc, argv, Repeat, Size) ) { |
1147 | return 1; |
1148 | } |
618617fe |
1149 | CompSparseArray (di, Repeat, Size); |
3a01a933 |
1150 | return 0; |
1151 | } |
1152 | |
1153 | void QANCollection::CommandsPerf(Draw_Interpretor& theCommands) { |
1154 | const char *group = "QANCollection"; |
1155 | |
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); |
1166 | |
1167 | theCommands.Add("QANColCheckSparseArray", "QANColCheckSparseArray Repeat Size", __FILE__, QANColCheckSparseArray, group); |
1168 | |
1169 | return; |
1170 | } |
1171 | |