0024742: Remove rarely used collection classes: Stack
[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 <TColgp_SequenceOfPnt.hxx>
21 #include <TColStd_SetOfInteger.hxx>
22
23 // ===================== Test perform of List type ==========================
24 void CompList (const Standard_Integer theRep,
25                const Standard_Integer theSize)
26 {
27   Standard_Integer i,j;
28
29   ////////////////////////////////Perf_Meter aNAppe ("NCollection_List appending",0);
30   ////////////////////////////////Perf_Meter aTAppe ("TCollection_List appending",0);
31   ////////////////////////////////Perf_Meter aNOper ("NCollection_List operator=",0);
32   ////////////////////////////////Perf_Meter aTOper ("TCollection_List operator=",0);
33   ////////////////////////////////Perf_Meter aNClea ("NCollection_List clearing",0);
34   ////////////////////////////////Perf_Meter aTClea ("TCollection_List clearing",0);
35   ////////////////////////////////Perf_Meter aNAssi ("NCollection_List Assign",0);
36   for (i=0; i<theRep; i++)
37     {
38       ////////////////////////////////QANCollection_List a1, a2;
39       QANCollection_ListPerf a1, a2;
40       ////////////////////////////////aNAppe.Start();
41       PERF_START_METER("NCollection_List appending")
42       for (j=1; j<=theSize; j++)
43         {
44           ItemType anItem;
45           Random(anItem);
46           a1.Append(anItem);
47         }
48       ////////////////////////////////aNAppe.Stop();
49       PERF_STOP_METER("NCollection_List appending")
50       ////////////////////////////////aNOper.Start();
51       PERF_START_METER("NCollection_List operator=")
52       a2 = a1;
53       ////////////////////////////////aNOper.Stop();
54       PERF_STOP_METER("NCollection_List operator=")
55       ////////////////////////////////aNAssi.Start();
56       PERF_START_METER("NCollection_List Assign")
57       a2.Assign(a1);
58       ////////////////////////////////aNAssi.Stop();
59       PERF_STOP_METER("NCollection_List Assign")
60       ////////////////////////////////aNClea.Start();
61       PERF_START_METER("NCollection_List clearing")
62       a2.Clear();
63       ////////////////////////////////aNClea.Stop();
64       PERF_STOP_METER("NCollection_List clearing")
65     }
66
67   for (i=0; i<theRep; i++)
68     {
69       QANCollection_ListOfPnt a1, a2;
70       ////////////////////////////////aTAppe.Start();
71       PERF_START_METER("TCollection_List appending")
72       for (j=1; j<=theSize; j++)
73         {
74           ItemType anItem;
75           Random(anItem);
76           a1.Append(anItem);
77         }
78       ////////////////////////////////aTAppe.Stop();
79       PERF_STOP_METER("TCollection_List appending")
80       ////////////////////////////////aTOper.Start();
81       PERF_START_METER("TCollection_List operator=")
82       a2 = a1;
83       ////////////////////////////////aTOper.Stop();
84       PERF_STOP_METER("TCollection_List operator=")
85       ////////////////////////////////aTClea.Start();
86       PERF_START_METER("TCollection_List clearing")
87       a2.Clear();
88       ////////////////////////////////aTClea.Stop();
89       PERF_STOP_METER("TCollection_List clearing")
90     }
91   PERF_PRINT_ALL
92 }
93
94
95 // ===================== Test perform of Set type ==========================
96 void CompSet (const Standard_Integer theRep,
97               const Standard_Integer theSize)
98 {
99   Standard_Integer i,j;
100
101   ////////////////////////////////Perf_Meter aNPush ("NCollection_Set pushing",0);
102   ////////////////////////////////Perf_Meter aTPush ("TCollection_Set pushing",0);
103   ////////////////////////////////Perf_Meter aNFind ("NCollection_Set finding",0);
104   ////////////////////////////////Perf_Meter aTFind ("TCollection_Set finding",0);
105   ////////////////////////////////Perf_Meter aNOper ("NCollection_Set operator=",0);
106   ////////////////////////////////Perf_Meter aTOper ("TCollection_Set operator=",0);
107   ////////////////////////////////Perf_Meter aNClea ("NCollection_Set clearing",0);
108   ////////////////////////////////Perf_Meter aTClea ("TCollection_Set clearing",0);
109   ////////////////////////////////Perf_Meter aNAssi ("NCollection_Set Assign",0);
110   for (i=0; i<theRep; i++)
111     {
112       ////////////////////////////////QANCollection_Set a1, a2;
113       QANCollection_SetPerf a1, a2;
114       ////////////////////////////////aNPush.Start();
115       PERF_START_METER("NCollection_Set pushing")
116       for (j=1; j<=theSize; j++)
117         {
118           Key2Type anItem;
119           Random(anItem);
120           a1.Add(anItem);
121         }
122       ////////////////////////////////aNPush.Stop();
123       PERF_STOP_METER("NCollection_Set pushing")
124       ////////////////////////////////aNFind.Start();
125       PERF_START_METER("NCollection_Set finding")
126       for (j=1; j<=theSize; j++)
127         {
128           Key2Type anItem;
129           Random(anItem);
130           a1.Contains(anItem);
131         }
132       ////////////////////////////////aNFind.Stop();
133       PERF_STOP_METER("NCollection_Set finding")
134       ////////////////////////////////aNOper.Start();
135       PERF_START_METER("NCollection_Set operator=")
136       a2 = a1;
137       ////////////////////////////////aNOper.Stop();
138       PERF_STOP_METER("NCollection_Set operator=")
139       ////////////////////////////////aNAssi.Start();
140       PERF_START_METER("NCollection_Set Assign")
141       a2.Assign(a1);
142       ////////////////////////////////aNAssi.Stop();
143       PERF_STOP_METER("NCollection_Set Assign")
144       ////////////////////////////////aNClea.Start();
145       PERF_START_METER("NCollection_Set clearing")
146       a2.Clear();
147       ////////////////////////////////aNClea.Stop();
148       PERF_STOP_METER("NCollection_Set clearing")
149     }
150
151   for (i=0; i<theRep; i++)
152     {
153       TColStd_SetOfInteger a1, a2;
154       ////////////////////////////////aTPush.Start();
155       PERF_START_METER("TCollection_Set pushing")
156       for (j=1; j<=theSize; j++)
157         {
158           Key2Type anItem;
159           Random(anItem);
160           a1.Add(anItem);
161         }
162       ////////////////////////////////aTPush.Stop();
163       PERF_STOP_METER("TCollection_Set pushing")
164       ////////////////////////////////aTFind.Start();
165       PERF_START_METER("TCollection_Set finding")
166         for (j=1; j<=theSize; j++)
167           {
168             Key2Type anItem;
169             Random(anItem);
170             a1.Contains(anItem);
171           }
172       ////////////////////////////////aTFind.Stop();
173       PERF_STOP_METER("TCollection_Set finding")
174       ////////////////////////////////aTOper.Start();
175       PERF_START_METER("TCollection_Set operator=")
176       a2 = a1;
177       ////////////////////////////////aTOper.Stop();
178       PERF_STOP_METER("TCollection_Set operator=")
179       ////////////////////////////////aTClea.Start();
180       PERF_START_METER("TCollection_Set clearing")
181       a2.Clear();
182       ////////////////////////////////aTClea.Stop();
183       PERF_STOP_METER("TCollection_Set clearing")
184     }
185   PERF_PRINT_ALL
186 }
187
188 // ===================== Test perform of Sequence type ==========================
189 void CompSequence (const Standard_Integer theRep,
190                    const Standard_Integer theSize)
191 {
192   Standard_Integer i,j;
193
194   ////////////////////////////////Perf_Meter aNAppe ("NCollection_Sequence appending",0);
195   ////////////////////////////////Perf_Meter aTAppe ("TCollection_Sequence appending",0);
196   ////////////////////////////////Perf_Meter aNFind ("NCollection_Sequence finding",0);
197   ////////////////////////////////Perf_Meter aTFind ("TCollection_Sequence finding",0);
198   ////////////////////////////////Perf_Meter aNOper ("NCollection_Sequence operator=",0);
199   ////////////////////////////////Perf_Meter aTOper ("TCollection_Sequence operator=",0);
200   ////////////////////////////////Perf_Meter aNClea ("NCollection_Sequence clearing",0);
201   ////////////////////////////////Perf_Meter aTClea ("TCollection_Sequence clearing",0);
202   ////////////////////////////////Perf_Meter aNAssi ("NCollection_Sequence Assign",0);
203   for (i=0; i<theRep; i++)
204     {
205       ////////////////////////////////QANCollection_Sequence a1, a2;
206       QANCollection_SequencePerf a1, a2;
207       ////////////////////////////////aNAppe.Start();
208       PERF_START_METER("NCollection_Sequence appending")
209       for (j=1; j<=theSize; j++)
210         {
211           ItemType anItem;
212           Random(anItem);
213           a1.Append(anItem);
214         }
215       ////////////////////////////////aNAppe.Stop();
216       PERF_STOP_METER("NCollection_Sequence appending")
217       ////////////////////////////////aNFind.Start();
218       PERF_START_METER("NCollection_Sequence finding")
219       for (j=1; j<=theSize; j++)
220         {
221           Standard_Integer iIndex;
222           Random(iIndex,theSize);
223           a1.Value(iIndex+1);
224         }
225       ////////////////////////////////aNFind.Stop();
226       PERF_STOP_METER("NCollection_Sequence finding")
227       ////////////////////////////////aNOper.Start();
228       PERF_START_METER("NCollection_Sequence operator=")
229       a2 = a1;
230       ////////////////////////////////aNOper.Stop();
231       PERF_STOP_METER("NCollection_Sequence operator=")
232       ////////////////////////////////aNAssi.Start();
233       PERF_START_METER("NCollection_Sequence Assign")
234       a2.Assign(a1);
235       ////////////////////////////////aNAssi.Stop();
236       PERF_STOP_METER("NCollection_Sequence Assign")
237       ////////////////////////////////aNClea.Start();
238       PERF_START_METER("NCollection_Sequence clearing")
239       a2.Clear();
240       ////////////////////////////////aNClea.Stop();
241       PERF_STOP_METER("NCollection_Sequence clearing")
242     }
243
244   for (i=0; i<theRep; i++)
245     {
246       TColgp_SequenceOfPnt a1, a2;
247       ////////////////////////////////aTAppe.Start();
248       PERF_START_METER("TCollection_Sequence appending")
249       for (j=1; j<=theSize; j++)
250         {
251           ItemType anItem;
252           Random(anItem);
253           a1.Append(anItem);
254         }
255       ////////////////////////////////aTAppe.Stop();
256       PERF_STOP_METER("TCollection_Sequence appending")
257       ////////////////////////////////aTFind.Start();
258       PERF_START_METER("TCollection_Sequence finding")
259       for (j=1; j<=theSize; j++)
260         {
261           Standard_Integer iIndex;
262           Random(iIndex,theSize);
263           a1.Value(iIndex+1);
264         }
265       ////////////////////////////////aTFind.Stop();
266       PERF_STOP_METER("TCollection_Sequence finding")
267       ////////////////////////////////aTOper.Start();
268       PERF_START_METER("TCollection_Sequence operator=")
269       a2 = a1;
270       ////////////////////////////////aTOper.Stop();
271       PERF_STOP_METER("TCollection_Sequence operator=")
272       ////////////////////////////////aTClea.Start();
273       PERF_START_METER("TCollection_Sequence clearing")
274       a2.Clear();
275       ////////////////////////////////aTClea.Stop();
276       PERF_STOP_METER("TCollection_Sequence clearing")
277     }
278   PERF_PRINT_ALL
279 }
280
281 #endif