0024186: Eliminate remaining compiler warnings in MSVC++ 2010 64 bit with warning...
[occt.git] / src / QANCollection / QANCollection_PerfMaps.hxx
CommitLineData
b311480e 1// Created on: 2002-04-30
2// Created by: Alexander KARTOMIN (akm)
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21
22#ifndef QANCollection_PerfMaps_HeaderFile
23#define QANCollection_PerfMaps_HeaderFile
24
25#include <TColStd_MapOfReal.hxx>
26#include <TColStd_IndexedMapOfReal.hxx>
27#include <QANCollection_DataMapOfRealPnt.hxx>
28#include <QANCollection_DoubleMapOfRealInteger.hxx>
29#include <QANCollection_IndexedDataMapOfRealPnt.hxx>
30
31// ===================== Test perform of Map type ==========================
32void CompMap (const Standard_Integer theRep,
33 const Standard_Integer theSize)
34{
35 Standard_Integer i,j;
36
37 ////////////////////////////////Perf_Meter aNBind ("NCollection_Map adding",0);
38 ////////////////////////////////Perf_Meter aTBind ("TCollection_Map adding",0);
39 ////////////////////////////////Perf_Meter aNOper ("NCollection_Map operator=",0);
40 ////////////////////////////////Perf_Meter aTOper ("TCollection_Map operator=",0);
41 ////////////////////////////////Perf_Meter aNFind ("NCollection_Map finding",0);
42 ////////////////////////////////Perf_Meter aTFind ("TCollection_Map finding",0);
43 ////////////////////////////////Perf_Meter aNClea ("NCollection_Map clearing",0);
44 ////////////////////////////////Perf_Meter aTClea ("TCollection_Map clearing",0);
45 ////////////////////////////////Perf_Meter aNAssi ("NCollection_Map Assign",0);
46 for (i=0; i<theRep; i++)
47 {
48 ////////////////////////////////QANCollection_Map a1, a2;
49 QANCollection_MapPerf a1, a2;
50 ////////////////////////////////aNBind.Start();
51 PERF_START_METER("NCollection_Map adding")
52 for (j=1; j<=theSize; j++)
53 {
54 Key1Type aKey1;
55 Random(aKey1);
56 a1.Add(aKey1);
57 }
58 ////////////////////////////////aNBind.Stop();
59 PERF_STOP_METER("NCollection_Map adding")
60 ////////////////////////////////aNFind.Start();
61 PERF_START_METER("NCollection_Map finding")
62 for (j=1; j<=theSize; j++)
63 {
64 Key1Type aKey1;
65 Random(aKey1);
66 a1.Contains(aKey1);
67 }
68 ////////////////////////////////aNFind.Stop();
69 PERF_STOP_METER("NCollection_Map finding")
70 ////////////////////////////////aNOper.Start();
71 PERF_START_METER("NCollection_Map operator=")
72 a2 = a1;
73 ////////////////////////////////aNOper.Stop();
74 PERF_STOP_METER("NCollection_Map operator=")
75 ////////////////////////////////aNAssi.Start();
76 PERF_START_METER("NCollection_Map Assign")
77 a2.Assign(a1);
78 ////////////////////////////////aNAssi.Stop();
79 PERF_STOP_METER("NCollection_Map Assign")
80 ////////////////////////////////aNClea.Start();
81 PERF_START_METER("NCollection_Map clearing")
82 a2.Clear();
83 ////////////////////////////////aNClea.Stop();
84 PERF_STOP_METER("NCollection_Map clearing")
85 }
86
87 for (i=0; i<theRep; i++)
88 {
89 TColStd_MapOfReal a1, a2;
90 ////////////////////////////////aTBind.Start();
91 PERF_START_METER("TCollection_Map adding")
92 for (j=1; j<=theSize; j++)
93 {
94 Key1Type aKey1;
95 Random(aKey1);
96 a1.Add(aKey1);
97 }
98 ////////////////////////////////aTBind.Stop();
99 PERF_STOP_METER("TCollection_Map adding")
100 ////////////////////////////////aTFind.Start();
101 PERF_START_METER("TCollection_Map finding")
102 for (j=1; j<=theSize; j++)
103 {
104 Key1Type aKey1;
105 Random(aKey1);
106 a1.Contains(aKey1);
107 }
108 ////////////////////////////////aTFind.Stop();
109 PERF_STOP_METER("TCollection_Map finding")
110 ////////////////////////////////aTOper.Start();
111 PERF_START_METER("TCollection_Map operator=")
112 a2 = a1;
113 ////////////////////////////////aTOper.Stop();
114 PERF_STOP_METER("TCollection_Map operator=")
115 ////////////////////////////////aTClea.Start();
116 PERF_START_METER("TCollection_Map clearing")
117 a2.Clear();
118 ////////////////////////////////aTClea.Stop();
119 PERF_STOP_METER("TCollection_Map clearing")
120 }
c2ae831c 121 PERF_PRINT_ALL
7fd59977 122}
123
124// ===================== Test perform of DataMap type ==========================
125void CompDataMap (const Standard_Integer theRep,
126 const Standard_Integer theSize)
127{
128 Standard_Integer i,j;
129
130 ////////////////////////////////Perf_Meter aNBind ("NCollection_DataMap binding",0);
131 ////////////////////////////////Perf_Meter aTBind ("TCollection_DataMap binding",0);
132 ////////////////////////////////Perf_Meter aNFind ("NCollection_DataMap finding",0);
133 ////////////////////////////////Perf_Meter aTFind ("TCollection_DataMap finding",0);
134 ////////////////////////////////Perf_Meter aNOper ("NCollection_DataMap operator=",0);
135 ////////////////////////////////Perf_Meter aTOper ("TCollection_DataMap operator=",0);
136 ////////////////////////////////Perf_Meter aNClea ("NCollection_DataMap clearing",0);
137 ////////////////////////////////Perf_Meter aTClea ("TCollection_DataMap clearing",0);
138 //////////////////////////////////Perf_Meter aNAssi ("NCollection_DataMap Assign",0);
139 for (i=0; i<theRep; i++)
140 {
141 ////////////////////////////////QANCollection_DataMap a1, a2;
142 QANCollection_DataMapPerf a1, a2;
143 ////////////////////////////////aNBind.Start();
144 PERF_START_METER("NCollection_DataMap binding")
145 for (j=1; j<=theSize; j++)
146 {
147 Key1Type aKey1;
148 ItemType anItem;
149 Random(aKey1);
150 Random(anItem);
151 a1.Bind(aKey1,anItem);
152 }
153 ////////////////////////////////aNBind.Stop();
154 PERF_STOP_METER("NCollection_DataMap binding")
155 ////////////////////////////////aNFind.Start();
156 PERF_START_METER("NCollection_DataMap finding")
157 for (j=1; j<=theSize; j++)
158 {
159 Key1Type aKey1;
160 Random(aKey1);
161 a1.IsBound(aKey1);
162 }
163 ////////////////////////////////aNFind.Stop();
164 PERF_STOP_METER("NCollection_DataMap finding")
165 ////////////////////////////////aNOper.Start();
166 PERF_START_METER("NCollection_DataMap operator=")
167 a2 = a1;
168 ////////////////////////////////aNOper.Stop();
169 PERF_STOP_METER("NCollection_DataMap operator=")
170 //aNAssi.Start();
171 //a2.Assign(a1);
172 //aNAssi.Stop();
173 ////////////////////////////////aNClea.Start();
174 PERF_START_METER("NCollection_DataMap clearing")
175 a2.Clear();
176 ////////////////////////////////aNClea.Stop();
177 PERF_STOP_METER("NCollection_DataMap clearing")
178 }
179
180 for (i=0; i<theRep; i++)
181 {
182 QANCollection_DataMapOfRealPnt a1, a2;
183 ////////////////////////////////aTBind.Start();
184 PERF_START_METER("TCollection_DataMap binding")
185 for (j=1; j<=theSize; j++)
186 {
187 Key1Type aKey1;
188 ItemType anItem;
189 Random(aKey1);
190 Random(anItem);
191 a1.Bind(aKey1,anItem);
192 }
193 ////////////////////////////////aTBind.Stop();
194 PERF_STOP_METER("TCollection_DataMap binding")
195 ////////////////////////////////aTFind.Start();
196 PERF_START_METER("TCollection_DataMap finding")
197 for (j=1; j<=theSize; j++)
198 {
199 Key1Type aKey1;
200 Random(aKey1);
201 a1.IsBound(aKey1);
202 }
203 ////////////////////////////////aTFind.Stop();
204 PERF_STOP_METER("TCollection_DataMap finding")
205 ////////////////////////////////aTOper.Start();
206 PERF_START_METER("TCollection_DataMap operator=")
207 a2 = a1;
208 ////////////////////////////////aTOper.Stop();
209 PERF_STOP_METER("TCollection_DataMap operator=")
210 ////////////////////////////////aTClea.Start();
211 PERF_START_METER("TCollection_DataMap clearing")
212 a2.Clear();
213 ////////////////////////////////aTClea.Stop();
214 PERF_STOP_METER("TCollection_DataMap clearing")
215 }
c2ae831c 216 PERF_PRINT_ALL
7fd59977 217}
218
219// ===================== Test perform of DoubleMap type ==========================
220void CompDoubleMap (const Standard_Integer theRep,
221 const Standard_Integer theSize)
222{
223 Standard_Integer i,j;
224 Standard_Integer iFail1=0, iFail2=0;
225
226 ////////////////////////////////Perf_Meter aNBind ("NCollection_DoubleMap binding",0);
227 ////////////////////////////////Perf_Meter aTBind ("TCollection_DoubleMap binding",0);
228 ////////////////////////////////Perf_Meter aNFind ("NCollection_DoubleMap finding",0);
229 ////////////////////////////////Perf_Meter aTFind ("TCollection_DoubleMap finding",0);
230 ////////////////////////////////Perf_Meter aNOper ("NCollection_DoubleMap operator=",0);
231 ////////////////////////////////Perf_Meter aTOper ("TCollection_DoubleMap operator=",0);
232 ////////////////////////////////Perf_Meter aNClea ("NCollection_DoubleMap clearing",0);
233 ////////////////////////////////Perf_Meter aTClea ("TCollection_DoubleMap clearing",0);
234 //////////////////////////////////Perf_Meter aNAssi ("NCollection_DoubleMap Assign",0);
235 for (i=0; i<theRep; i++)
236 {
237 ////////////////////////////////QANCollection_DoubleMap a1, a2;
238 QANCollection_DoubleMapPerf a1, a2;
239 ////////////////////////////////aNBind.Start();
240 PERF_START_METER("NCollection_DoubleMap binding")
241 for (j=1; j<=theSize; j++)
242 {
243 Key1Type aKey1;
244 Key2Type aKey2;
245 do {
246 Random(aKey1);
247 Random(aKey2);
248 iFail1++;
249 }
250 while (a1.IsBound1(aKey1) || a1.IsBound2(aKey2));
251 iFail1--;
252 a1.Bind(aKey1,aKey2);
253 }
254 ////////////////////////////////aNBind.Stop();
255 PERF_STOP_METER("NCollection_DoubleMap binding")
256 ////////////////////////////////aNFind.Start();
257 PERF_START_METER("NCollection_DoubleMap finding")
258 for (j=1; j<=theSize; j++)
259 {
260 Key1Type aKey1;
261 Key2Type aKey2;
262 Random(aKey1);
263 Random(aKey2);
264 a1.AreBound(aKey1,aKey2);
265 }
266 ////////////////////////////////aNFind.Stop();
267 PERF_STOP_METER("NCollection_DoubleMap finding")
268 ////////////////////////////////aNOper.Start();
269 PERF_START_METER("NCollection_DoubleMap operator=")
270 a2 = a1;
271 ////////////////////////////////aNOper.Stop();
272 PERF_STOP_METER("NCollection_DoubleMap operator=")
273 //aNAssi.Start();
274 //a2.Assign(a1);
275 //aNAssi.Stop();
276 ////////////////////////////////aNClea.Start();
277 PERF_START_METER("NCollection_DoubleMap clearing")
278 a2.Clear();
279 ////////////////////////////////aNClea.Stop();
280 PERF_STOP_METER("NCollection_DoubleMap clearing")
281 }
282
283 for (i=0; i<theRep; i++)
284 {
285 QANCollection_DoubleMapOfRealInteger a1, a2;
286 ////////////////////////////////aTBind.Start();
287 PERF_START_METER("TCollection_DoubleMap binding")
288 for (j=1; j<=theSize; j++)
289 {
290 Key1Type aKey1;
291 Key2Type aKey2;
292 do {
293 Random(aKey1);
294 Random(aKey2);
295 iFail2++;
296 }
297 while (a1.IsBound1(aKey1) || a1.IsBound2(aKey2));
298 iFail2--;
299 a1.Bind(aKey1,aKey2);
300 }
301 ////////////////////////////////aTBind.Stop();
302 PERF_STOP_METER("TCollection_DoubleMap binding")
303 ////////////////////////////////aTFind.Start();
304 PERF_START_METER("TCollection_DoubleMap finding")
305 for (j=1; j<=theSize; j++)
306 {
307 Key1Type aKey1;
308 Key2Type aKey2;
309 Random(aKey1);
310 Random(aKey2);
311 a1.AreBound(aKey1,aKey2);
312 }
313 ////////////////////////////////aTFind.Stop();
314 PERF_STOP_METER("TCollection_DoubleMap finding")
315 ////////////////////////////////aTOper.Start();
316 PERF_START_METER("TCollection_DoubleMap operator=")
317 a2 = a1;
318 ////////////////////////////////aTOper.Stop();
319 PERF_STOP_METER("TCollection_DoubleMap operator=")
320 ////////////////////////////////aTClea.Start();
321 PERF_START_METER("TCollection_DoubleMap clearing")
322 a2.Clear();
323 ////////////////////////////////aTClea.Stop();
324 PERF_STOP_METER("TCollection_DoubleMap clearing")
325 }
c2ae831c 326 PERF_PRINT_ALL
7fd59977 327 if (iFail1 || iFail2)
328 cout << "Warning : N map failed " << iFail1 << " times, T map - " <<
329 iFail2 << endl;
330}
331
332// ===================== Test perform of IndexedMap type ==========================
333void CompIndexedMap (const Standard_Integer theRep,
334 const Standard_Integer theSize)
335{
336 Standard_Integer i,j;
337
338 ////////////////////////////////Perf_Meter aNBind ("NCollection_IndexedMap adding",0);
339 ////////////////////////////////Perf_Meter aTBind ("TCollection_IndexedMap adding",0);
340 ////////////////////////////////Perf_Meter aNOper ("NCollection_IndexedMap operator=",0);
341 ////////////////////////////////Perf_Meter aTOper ("TCollection_IndexedMap operator=",0);
342 ////////////////////////////////Perf_Meter aNFind ("NCollection_IndexedMap finding",0);
343 ////////////////////////////////Perf_Meter aTFind ("TCollection_IndexedMap finding",0);
344 ////////////////////////////////Perf_Meter aNClea ("NCollection_IndexedMap clearing",0);
345 ////////////////////////////////Perf_Meter aTClea ("TCollection_IndexedMap clearing",0);
346 ////////////////////////////////Perf_Meter aNAssi ("NCollection_IndexedMap Assign",0);
347
348 for (i=0; i<theRep; i++)
349 {
350 ////////////////////////////////QANCollection_IndexedMap a1, a2;
351 QANCollection_IndexedMapPerf a1, a2;
352 ////////////////////////////////aNBind.Start();
353 PERF_START_METER("NCollection_IndexedMap adding")
354 for (j=1; j<=theSize; j++)
355 {
356 Key1Type aKey1;
357 Random(aKey1);
358 a1.Add(aKey1);
359 }
360 ////////////////////////////////aNBind.Stop();
361 PERF_STOP_METER("NCollection_IndexedMap adding")
362 ////////////////////////////////aNFind.Start();
363 PERF_START_METER("NCollection_IndexedMap finding")
364 for (j=1; j<=theSize; j++)
365 {
366 Key1Type aKey1;
367 Random(aKey1);
368 a1.Contains(aKey1);
369 }
370 ////////////////////////////////aNFind.Stop();
371 PERF_STOP_METER("NCollection_IndexedMap finding")
372 ////////////////////////////////aNOper.Start();
373 PERF_START_METER("NCollection_IndexedMap operator=")
374 a2 = a1;
375 ////////////////////////////////aNOper.Stop();
376 PERF_STOP_METER("NCollection_IndexedMap operator=")
377 ////////////////////////////////aNAssi.Start();
378 PERF_START_METER("NCollection_IndexedMap Assign")
379 a2.Assign(a1);
380 ////////////////////////////////aNAssi.Stop();
381 PERF_STOP_METER("NCollection_IndexedMap Assign")
382 ////////////////////////////////aNClea.Start();
383 PERF_START_METER("NCollection_IndexedMap clearing")
384 a2.Clear();
385 ////////////////////////////////aNClea.Stop();
386 PERF_STOP_METER("NCollection_IndexedMap clearing")
387 }
388
389 for (i=0; i<theRep; i++)
390 {
391 TColStd_IndexedMapOfReal a1, a2;
392 ////////////////////////////////aTBind.Start();
393 PERF_START_METER("TCollection_IndexedMap adding")
394 for (j=1; j<=theSize; j++)
395 {
396 Key1Type aKey1;
397 Random(aKey1);
398 a1.Add(aKey1);
399 }
400 ////////////////////////////////aTBind.Stop();
401 PERF_STOP_METER("TCollection_IndexedMap adding")
402 ////////////////////////////////aTFind.Start();
403 PERF_START_METER("TCollection_IndexedMap finding")
404 for (j=1; j<=theSize; j++)
405 {
406 Key1Type aKey1;
407 Random(aKey1);
408 a1.Contains(aKey1);
409 }
410 ////////////////////////////////aTFind.Stop();
411 PERF_STOP_METER("TCollection_IndexedMap finding")
412 ////////////////////////////////aTOper.Start();
413 PERF_START_METER("TCollection_IndexedMap operator=")
414 a2 = a1;
415 ////////////////////////////////aTOper.Stop();
416 PERF_STOP_METER("TCollection_IndexedMap operator=")
417 ////////////////////////////////aTClea.Start();
418 PERF_START_METER("TCollection_IndexedMap clearing")
419 a2.Clear();
420 ////////////////////////////////aTClea.Stop();
421 PERF_STOP_METER("TCollection_IndexedMap clearing")
422 }
c2ae831c 423 PERF_PRINT_ALL
7fd59977 424}
425
426// ===================== Test perform of IndexedDataMap type ==========================
427void CompIndexedDataMap (const Standard_Integer theRep,
428 const Standard_Integer theSize)
429{
430 Standard_Integer i,j;
431
432 ////////////////////////////////Perf_Meter aNBind ("NCollection_IndexedDataMap binding",0);
433 ////////////////////////////////Perf_Meter aTBind ("TCollection_IndexedDataMap binding",0);
434 ////////////////////////////////Perf_Meter aNFind ("NCollection_IndexedDataMap finding",0);
435 ////////////////////////////////Perf_Meter aTFind ("TCollection_IndexedDataMap finding",0);
436 ////////////////////////////////Perf_Meter aNOper ("NCollection_IndexedDataMap operator=",0);
437 ////////////////////////////////Perf_Meter aTOper ("TCollection_IndexedDataMap operator=",0);
438 ////////////////////////////////Perf_Meter aNClea ("NCollection_IndexedDataMap clearing",0);
439 ////////////////////////////////Perf_Meter aTClea ("TCollection_IndexedDataMap clearing",0);
440 //////////////////////////////////Perf_Meter aNAssi ("NCollection_IndexedDataMap Assign",0);
441
442 for (i=0; i<theRep; i++)
443 {
444 ////////////////////////////////QANCollection_IDMap a1, a2;
445 QANCollection_IDMapPerf a1, a2;
446 ////////////////////////////////aNBind.Start();
447 PERF_START_METER("NCollection_IndexedDataMap binding")
448 for (j=1; j<=theSize; j++)
449 {
450 Key1Type aKey1;
451 ItemType anItem;
452 Random(aKey1);
453 Random(anItem);
454 a1.Add(aKey1,anItem);
455 }
456 ////////////////////////////////aNBind.Stop();
457 PERF_STOP_METER("NCollection_IndexedDataMap binding")
458 ////////////////////////////////aNFind.Start();
459 PERF_START_METER("NCollection_IndexedDataMap finding")
460 for (j=1; j<=theSize; j++)
461 {
462 Key1Type aKey1;
463 Random(aKey1);
464 a1.Contains(aKey1);
465 }
466 ////////////////////////////////aNFind.Stop();
467 PERF_STOP_METER("NCollection_IndexedDataMap finding")
468 ////////////////////////////////aNOper.Start();
469 PERF_START_METER("NCollection_IndexedDataMap operator=")
470 a2 = a1;
471 ////////////////////////////////aNOper.Stop();
472 PERF_STOP_METER("NCollection_IndexedDataMap operator=")
473 //aNAssi.Start();
474 //a2.Assign(a1);
475 //aNAssi.Stop();
476 ////////////////////////////////aNClea.Start();
477 PERF_START_METER("NCollection_IndexedDataMap clearing")
478 a2.Clear();
479 ////////////////////////////////aNClea.Stop();
480 PERF_STOP_METER("NCollection_IndexedDataMap clearing")
481 }
482
483 for (i=0; i<theRep; i++)
484 {
485 QANCollection_IndexedDataMapOfRealPnt a1, a2;
486 ////////////////////////////////aTBind.Start();
487 PERF_START_METER("TCollection_IndexedDataMap binding")
488 for (j=1; j<=theSize; j++)
489 {
490 Key1Type aKey1;
491 ItemType anItem;
492 Random(aKey1);
493 Random(anItem);
494 a1.Add(aKey1,anItem);
495 }
496 ////////////////////////////////aTBind.Stop();
497 PERF_STOP_METER("TCollection_IndexedDataMap binding")
498 ////////////////////////////////aTFind.Start();
499 PERF_START_METER("TCollection_IndexedDataMap finding")
500 for (j=1; j<=theSize; j++)
501 {
502 Key1Type aKey1;
503 Random(aKey1);
504 a1.Contains(aKey1);
505 }
506 ////////////////////////////////aTFind.Stop();
507 PERF_STOP_METER("TCollection_IndexedDataMap finding")
508 ////////////////////////////////aTOper.Start();
509 PERF_START_METER("TCollection_IndexedDataMap operator=")
510 a2 = a1;
511 ////////////////////////////////aTOper.Stop();
512 PERF_STOP_METER("TCollection_IndexedDataMap operator=")
513 ////////////////////////////////aTClea.Start();
514 PERF_START_METER("TCollection_IndexedDataMap clearing")
515 a2.Clear();
516 ////////////////////////////////aTClea.Stop();
517 PERF_STOP_METER("TCollection_IndexedDataMap clearing")
518 }
c2ae831c 519 PERF_PRINT_ALL
7fd59977 520}
521
522#endif