84b05479964c5c96cf81f178fafad478a3f875f6
[occt.git] / src / QANCollection / QANCollection_PerfLists.hxx
1 // Created on: 2002-04-30
2 // Created by: Alexander KARTOMIN (akm)
3 // Copyright (c) 2002-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 #ifndef QANCollection_PerfLists_HeaderFile
17 #define QANCollection_PerfLists_HeaderFile
18
19 #include <QANCollection_ListOfPnt.hxx>
20 #include <QANCollection_StackOfPnt.hxx>
21 #include <TColgp_SequenceOfPnt.hxx>
22 #include <TColStd_SetOfInteger.hxx>
23
24 // ===================== Test perform of List type ==========================
25 void CompList (const Standard_Integer theRep,
26                const Standard_Integer theSize)
27 {
28   Standard_Integer i,j;
29
30   ////////////////////////////////Perf_Meter aNAppe ("NCollection_List appending",0);
31   ////////////////////////////////Perf_Meter aTAppe ("TCollection_List appending",0);
32   ////////////////////////////////Perf_Meter aNOper ("NCollection_List operator=",0);
33   ////////////////////////////////Perf_Meter aTOper ("TCollection_List operator=",0);
34   ////////////////////////////////Perf_Meter aNClea ("NCollection_List clearing",0);
35   ////////////////////////////////Perf_Meter aTClea ("TCollection_List clearing",0);
36   ////////////////////////////////Perf_Meter aNAssi ("NCollection_List Assign",0);
37   for (i=0; i<theRep; i++)
38     {
39       ////////////////////////////////QANCollection_List a1, a2;
40       QANCollection_ListPerf a1, a2;
41       ////////////////////////////////aNAppe.Start();
42       PERF_START_METER("NCollection_List appending")
43       for (j=1; j<=theSize; j++)
44         {
45           ItemType anItem;
46           Random(anItem);
47           a1.Append(anItem);
48         }
49       ////////////////////////////////aNAppe.Stop();
50       PERF_STOP_METER("NCollection_List appending")
51       ////////////////////////////////aNOper.Start();
52       PERF_START_METER("NCollection_List operator=")
53       a2 = a1;
54       ////////////////////////////////aNOper.Stop();
55       PERF_STOP_METER("NCollection_List operator=")
56       ////////////////////////////////aNAssi.Start();
57       PERF_START_METER("NCollection_List Assign")
58       a2.Assign(a1);
59       ////////////////////////////////aNAssi.Stop();
60       PERF_STOP_METER("NCollection_List Assign")
61       ////////////////////////////////aNClea.Start();
62       PERF_START_METER("NCollection_List clearing")
63       a2.Clear();
64       ////////////////////////////////aNClea.Stop();
65       PERF_STOP_METER("NCollection_List clearing")
66     }
67
68   for (i=0; i<theRep; i++)
69     {
70       QANCollection_ListOfPnt a1, a2;
71       ////////////////////////////////aTAppe.Start();
72       PERF_START_METER("TCollection_List appending")
73       for (j=1; j<=theSize; j++)
74         {
75           ItemType anItem;
76           Random(anItem);
77           a1.Append(anItem);
78         }
79       ////////////////////////////////aTAppe.Stop();
80       PERF_STOP_METER("TCollection_List appending")
81       ////////////////////////////////aTOper.Start();
82       PERF_START_METER("TCollection_List operator=")
83       a2 = a1;
84       ////////////////////////////////aTOper.Stop();
85       PERF_STOP_METER("TCollection_List operator=")
86       ////////////////////////////////aTClea.Start();
87       PERF_START_METER("TCollection_List clearing")
88       a2.Clear();
89       ////////////////////////////////aTClea.Stop();
90       PERF_STOP_METER("TCollection_List clearing")
91     }
92   PERF_PRINT_ALL
93 }
94
95
96 // ===================== Test perform of Stack type ==========================
97 void CompStack (const Standard_Integer theRep,
98                 const Standard_Integer theSize)
99 {
100   Standard_Integer i,j;
101
102   ////////////////////////////////Perf_Meter aNPush ("NCollection_Stack pushing",0);
103   ////////////////////////////////Perf_Meter aTPush ("TCollection_Stack pushing",0);
104   ////////////////////////////////Perf_Meter aNPopp ("NCollection_Stack popping",0);
105   ////////////////////////////////Perf_Meter aTPopp ("TCollection_Stack popping",0);
106   ////////////////////////////////Perf_Meter aNOper ("NCollection_Stack operator=",0);
107   ////////////////////////////////Perf_Meter aTOper ("TCollection_Stack operator=",0);
108   ////////////////////////////////Perf_Meter aNClea ("NCollection_Stack clearing",0);
109   ////////////////////////////////Perf_Meter aTClea ("TCollection_Stack clearing",0);
110   ////////////////////////////////Perf_Meter aNAssi ("NCollection_Stack Assign",0);
111   for (i=0; i<theRep; i++)
112     {
113       ////////////////////////////////QANCollection_Stack a1, a2;
114       QANCollection_StackPerf a1, a2;
115       ////////////////////////////////aNPush.Start();
116       PERF_START_METER("NCollection_Stack pushing")
117       for (j=1; j<=theSize; j++)
118         {
119           ItemType anItem;
120           Random(anItem);
121           a1.Push(anItem);
122         }
123       ////////////////////////////////aNPush.Stop();
124       PERF_STOP_METER("NCollection_Stack pushing")
125       ////////////////////////////////aNOper.Start();
126       PERF_START_METER("NCollection_Stack operator=")
127       a2 = a1;
128       ////////////////////////////////aNOper.Stop();
129       PERF_STOP_METER("NCollection_Stack operator=")
130       ////////////////////////////////aNAssi.Start();
131       PERF_START_METER("NCollection_Stack Assign")
132       a2.Assign(a1);
133       ////////////////////////////////aNAssi.Stop();
134       PERF_STOP_METER("NCollection_Stack Assign")
135       ////////////////////////////////aNPopp.Start();
136       PERF_START_METER("NCollection_Stack popping")
137       for (j=1; j<=theSize; j++)
138         a1.Pop();
139       ////////////////////////////////aNPopp.Stop();
140       PERF_STOP_METER("NCollection_Stack popping")
141       ////////////////////////////////aNClea.Start();
142       PERF_START_METER("NCollection_Stack clearing")
143       a2.Clear();
144       ////////////////////////////////aNClea.Stop();
145       PERF_STOP_METER("NCollection_Stack clearing")
146     }
147
148   for (i=0; i<theRep; i++)
149     {
150       QANCollection_StackOfPnt a1, a2;
151       ////////////////////////////////aTPush.Start();
152       PERF_START_METER("TCollection_Stack pushing")
153       for (j=1; j<=theSize; j++)
154         {
155           ItemType anItem;
156           Random(anItem);
157           a1.Push(anItem);
158         }
159       ////////////////////////////////aTPush.Stop();
160       PERF_STOP_METER("TCollection_Stack pushing")
161       ////////////////////////////////aTOper.Start();
162       PERF_START_METER("TCollection_Stack operator=")
163       a2 = a1;
164       ////////////////////////////////aTOper.Stop();
165       PERF_STOP_METER("TCollection_Stack operator=")
166       ////////////////////////////////aTPopp.Start();
167       PERF_START_METER("TCollection_Stack popping")
168       for (j=1; j<=theSize; j++)
169         a1.Pop();
170       ////////////////////////////////aTPopp.Stop();
171       PERF_STOP_METER("TCollection_Stack popping")
172       ////////////////////////////////aTClea.Start();
173       PERF_START_METER("TCollection_Stack clearing")
174       a2.Clear();
175       ////////////////////////////////aTClea.Stop();
176       PERF_STOP_METER("TCollection_Stack clearing")
177     }
178   PERF_PRINT_ALL
179 }
180
181
182 // ===================== Test perform of Set type ==========================
183 void CompSet (const Standard_Integer theRep,
184               const Standard_Integer theSize)
185 {
186   Standard_Integer i,j;
187
188   ////////////////////////////////Perf_Meter aNPush ("NCollection_Set pushing",0);
189   ////////////////////////////////Perf_Meter aTPush ("TCollection_Set pushing",0);
190   ////////////////////////////////Perf_Meter aNFind ("NCollection_Set finding",0);
191   ////////////////////////////////Perf_Meter aTFind ("TCollection_Set finding",0);
192   ////////////////////////////////Perf_Meter aNOper ("NCollection_Set operator=",0);
193   ////////////////////////////////Perf_Meter aTOper ("TCollection_Set operator=",0);
194   ////////////////////////////////Perf_Meter aNClea ("NCollection_Set clearing",0);
195   ////////////////////////////////Perf_Meter aTClea ("TCollection_Set clearing",0);
196   ////////////////////////////////Perf_Meter aNAssi ("NCollection_Set Assign",0);
197   for (i=0; i<theRep; i++)
198     {
199       ////////////////////////////////QANCollection_Set a1, a2;
200       QANCollection_SetPerf a1, a2;
201       ////////////////////////////////aNPush.Start();
202       PERF_START_METER("NCollection_Set pushing")
203       for (j=1; j<=theSize; j++)
204         {
205           Key2Type anItem;
206           Random(anItem);
207           a1.Add(anItem);
208         }
209       ////////////////////////////////aNPush.Stop();
210       PERF_STOP_METER("NCollection_Set pushing")
211       ////////////////////////////////aNFind.Start();
212       PERF_START_METER("NCollection_Set finding")
213       for (j=1; j<=theSize; j++)
214         {
215           Key2Type anItem;
216           Random(anItem);
217           a1.Contains(anItem);
218         }
219       ////////////////////////////////aNFind.Stop();
220       PERF_STOP_METER("NCollection_Set finding")
221       ////////////////////////////////aNOper.Start();
222       PERF_START_METER("NCollection_Set operator=")
223       a2 = a1;
224       ////////////////////////////////aNOper.Stop();
225       PERF_STOP_METER("NCollection_Set operator=")
226       ////////////////////////////////aNAssi.Start();
227       PERF_START_METER("NCollection_Set Assign")
228       a2.Assign(a1);
229       ////////////////////////////////aNAssi.Stop();
230       PERF_STOP_METER("NCollection_Set Assign")
231       ////////////////////////////////aNClea.Start();
232       PERF_START_METER("NCollection_Set clearing")
233       a2.Clear();
234       ////////////////////////////////aNClea.Stop();
235       PERF_STOP_METER("NCollection_Set clearing")
236     }
237
238   for (i=0; i<theRep; i++)
239     {
240       TColStd_SetOfInteger a1, a2;
241       ////////////////////////////////aTPush.Start();
242       PERF_START_METER("TCollection_Set pushing")
243       for (j=1; j<=theSize; j++)
244         {
245           Key2Type anItem;
246           Random(anItem);
247           a1.Add(anItem);
248         }
249       ////////////////////////////////aTPush.Stop();
250       PERF_STOP_METER("TCollection_Set pushing")
251       ////////////////////////////////aTFind.Start();
252       PERF_START_METER("TCollection_Set finding")
253         for (j=1; j<=theSize; j++)
254           {
255             Key2Type anItem;
256             Random(anItem);
257             a1.Contains(anItem);
258           }
259       ////////////////////////////////aTFind.Stop();
260       PERF_STOP_METER("TCollection_Set finding")
261       ////////////////////////////////aTOper.Start();
262       PERF_START_METER("TCollection_Set operator=")
263       a2 = a1;
264       ////////////////////////////////aTOper.Stop();
265       PERF_STOP_METER("TCollection_Set operator=")
266       ////////////////////////////////aTClea.Start();
267       PERF_START_METER("TCollection_Set clearing")
268       a2.Clear();
269       ////////////////////////////////aTClea.Stop();
270       PERF_STOP_METER("TCollection_Set clearing")
271     }
272   PERF_PRINT_ALL
273 }
274
275 // ===================== Test perform of Sequence type ==========================
276 void CompSequence (const Standard_Integer theRep,
277                    const Standard_Integer theSize)
278 {
279   Standard_Integer i,j;
280
281   ////////////////////////////////Perf_Meter aNAppe ("NCollection_Sequence appending",0);
282   ////////////////////////////////Perf_Meter aTAppe ("TCollection_Sequence appending",0);
283   ////////////////////////////////Perf_Meter aNFind ("NCollection_Sequence finding",0);
284   ////////////////////////////////Perf_Meter aTFind ("TCollection_Sequence finding",0);
285   ////////////////////////////////Perf_Meter aNOper ("NCollection_Sequence operator=",0);
286   ////////////////////////////////Perf_Meter aTOper ("TCollection_Sequence operator=",0);
287   ////////////////////////////////Perf_Meter aNClea ("NCollection_Sequence clearing",0);
288   ////////////////////////////////Perf_Meter aTClea ("TCollection_Sequence clearing",0);
289   ////////////////////////////////Perf_Meter aNAssi ("NCollection_Sequence Assign",0);
290   for (i=0; i<theRep; i++)
291     {
292       ////////////////////////////////QANCollection_Sequence a1, a2;
293       QANCollection_SequencePerf a1, a2;
294       ////////////////////////////////aNAppe.Start();
295       PERF_START_METER("NCollection_Sequence appending")
296       for (j=1; j<=theSize; j++)
297         {
298           ItemType anItem;
299           Random(anItem);
300           a1.Append(anItem);
301         }
302       ////////////////////////////////aNAppe.Stop();
303       PERF_STOP_METER("NCollection_Sequence appending")
304       ////////////////////////////////aNFind.Start();
305       PERF_START_METER("NCollection_Sequence finding")
306       for (j=1; j<=theSize; j++)
307         {
308           Standard_Integer iIndex;
309           Random(iIndex,theSize);
310           a1.Value(iIndex+1);
311         }
312       ////////////////////////////////aNFind.Stop();
313       PERF_STOP_METER("NCollection_Sequence finding")
314       ////////////////////////////////aNOper.Start();
315       PERF_START_METER("NCollection_Sequence operator=")
316       a2 = a1;
317       ////////////////////////////////aNOper.Stop();
318       PERF_STOP_METER("NCollection_Sequence operator=")
319       ////////////////////////////////aNAssi.Start();
320       PERF_START_METER("NCollection_Sequence Assign")
321       a2.Assign(a1);
322       ////////////////////////////////aNAssi.Stop();
323       PERF_STOP_METER("NCollection_Sequence Assign")
324       ////////////////////////////////aNClea.Start();
325       PERF_START_METER("NCollection_Sequence clearing")
326       a2.Clear();
327       ////////////////////////////////aNClea.Stop();
328       PERF_STOP_METER("NCollection_Sequence clearing")
329     }
330
331   for (i=0; i<theRep; i++)
332     {
333       TColgp_SequenceOfPnt a1, a2;
334       ////////////////////////////////aTAppe.Start();
335       PERF_START_METER("TCollection_Sequence appending")
336       for (j=1; j<=theSize; j++)
337         {
338           ItemType anItem;
339           Random(anItem);
340           a1.Append(anItem);
341         }
342       ////////////////////////////////aTAppe.Stop();
343       PERF_STOP_METER("TCollection_Sequence appending")
344       ////////////////////////////////aTFind.Start();
345       PERF_START_METER("TCollection_Sequence finding")
346       for (j=1; j<=theSize; j++)
347         {
348           Standard_Integer iIndex;
349           Random(iIndex,theSize);
350           a1.Value(iIndex+1);
351         }
352       ////////////////////////////////aTFind.Stop();
353       PERF_STOP_METER("TCollection_Sequence finding")
354       ////////////////////////////////aTOper.Start();
355       PERF_START_METER("TCollection_Sequence operator=")
356       a2 = a1;
357       ////////////////////////////////aTOper.Stop();
358       PERF_STOP_METER("TCollection_Sequence operator=")
359       ////////////////////////////////aTClea.Start();
360       PERF_START_METER("TCollection_Sequence clearing")
361       a2.Clear();
362       ////////////////////////////////aTClea.Stop();
363       PERF_STOP_METER("TCollection_Sequence clearing")
364     }
365   PERF_PRINT_ALL
366 }
367
368 #endif