0024157: Parallelization of assembly part of BO
[occt.git] / src / QANCollection / QANCollection_PerfArrays.hxx
1 // Created on: 2002-05-15
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
20
21
22 #ifndef QANCollection_PerfArrays_HeaderFile
23 #define QANCollection_PerfArrays_HeaderFile
24
25 #define PERF_ENABLE_METERS
26 #include <OSD_PerfMeter.hxx>
27 ////////////////////////////////#include <Perf_Meter.hxx>
28 #include <TColgp_Array1OfPnt.hxx>
29 #include <TColgp_Array2OfPnt.hxx>
30
31 // ===================== Test perform of Array1 type ==========================
32 void CompArray1 (const Standard_Integer theRep,
33                  const Standard_Integer theSize)
34 {
35   Standard_Integer i,j;
36
37   ////////////////////////////////Perf_Meter aNCrea ("NCollection_Array1 creation",0);
38   ////////////////////////////////Perf_Meter aTCrea ("TCollection_Array1 creation",0);
39   ////////////////////////////////Perf_Meter aNFill ("NCollection_Array1 filling",0);
40   ////////////////////////////////Perf_Meter aTFill ("TCollection_Array1 filling",0);
41   ////////////////////////////////Perf_Meter aNFind ("NCollection_Array1 finding",0);
42   ////////////////////////////////Perf_Meter aTFind ("TCollection_Array1 finding",0);
43   ////////////////////////////////Perf_Meter aNOper ("NCollection_Array1 operator=",0);
44   ////////////////////////////////Perf_Meter aTOper ("TCollection_Array1 operator=",0);
45   ////////////////////////////////Perf_Meter aNAssi ("NCollection_Array1 Assign",0);
46   for (i=0; i<theRep; i++)
47     {
48       ////////////////////////////////aNCrea.Start();
49       PERF_START_METER("NCollection_Array1 creation")
50       ////////////////////////////////QANCollection_Array1 a1(1,theSize), a2(1,theSize);
51       QANCollection_Array1Perf a1(1,theSize), a2(1,theSize);
52       ////////////////////////////////aNCrea.Stop();
53       PERF_STOP_METER("NCollection_Array1 creation")
54       ////////////////////////////////aNFill.Start();
55       PERF_START_METER("NCollection_Array1 filling")
56       for (j=1; j<=theSize; j++)
57         Random(a1(j));
58       ////////////////////////////////aNFill.Stop();
59       PERF_STOP_METER("NCollection_Array1 filling")
60       ////////////////////////////////aNFind.Start();
61       PERF_START_METER("NCollection_Array1 finding")
62       for (j=1; j<=theSize; j++)
63         {
64           Standard_Integer iIndex;
65           Random(iIndex,theSize);
66           a1.Value(iIndex+1);
67         }
68       ////////////////////////////////aNFind.Stop();
69       PERF_STOP_METER("NCollection_Array1 finding")
70       ////////////////////////////////aNOper.Start();
71       PERF_START_METER("NCollection_Array1 operator=")
72       a2 = a1;
73       ////////////////////////////////aNOper.Stop();
74       PERF_STOP_METER("NCollection_Array1 operator=")
75       ////////////////////////////////aNAssi.Start();
76       PERF_START_METER("NCollection_Array1 Assign")
77       a2.Assign(a1);
78       ////////////////////////////////aNAssi.Stop();
79       PERF_STOP_METER("NCollection_Array1 Assign")
80     }
81
82   for (i=0; i<theRep; i++)
83     {
84       ////////////////////////////////aTCrea.Start();
85       PERF_START_METER("TCollection_Array1 creation")
86       TColgp_Array1OfPnt a1(1,theSize), a2(1,theSize);
87       ////////////////////////////////aTCrea.Stop();
88       PERF_STOP_METER("TCollection_Array1 creation")
89       ////////////////////////////////aTFill.Start();
90       PERF_START_METER("TCollection_Array1 filling")
91       for (j=1; j<=theSize; j++)
92         Random(a1(j));
93       ////////////////////////////////aTFill.Stop();
94       PERF_STOP_METER("TCollection_Array1 filling")
95       ////////////////////////////////aTFind.Start();
96       PERF_START_METER("TCollection_Array1 finding")
97       for (j=1; j<=theSize; j++)
98         {
99           Standard_Integer iIndex;
100           Random(iIndex,theSize);
101           a1.Value(iIndex+1);
102         }
103       ////////////////////////////////aTFind.Stop();
104       PERF_STOP_METER("TCollection_Array1 finding")
105       ////////////////////////////////aTOper.Start();
106       PERF_START_METER("TCollection_Array1 operator=")
107       a2 = a1;
108       ////////////////////////////////aTOper.Stop();
109       PERF_STOP_METER("TCollection_Array1 operator=")
110     }
111   PERF_PRINT_ALL
112 }
113
114 // ===================== Test perform of Array2 type ==========================
115 void CompArray2 (const Standard_Integer theRep,
116                  const Standard_Integer theSize)
117 {
118   Standard_Integer i,j,k;
119   
120   ////////////////////////////////Perf_Meter aNCrea ("NCollection_Array2 creation",0);
121   ////////////////////////////////Perf_Meter aTCrea ("TCollection_Array2 creation",0);
122   ////////////////////////////////Perf_Meter aNFill ("NCollection_Array2 filling",0);
123   ////////////////////////////////Perf_Meter aTFill ("TCollection_Array2 filling",0);
124   ////////////////////////////////Perf_Meter aNFind ("NCollection_Array2 finding",0);
125   ////////////////////////////////Perf_Meter aTFind ("TCollection_Array2 finding",0);
126   ////////////////////////////////Perf_Meter aNOper ("NCollection_Array2 operator=",0);
127   ////////////////////////////////Perf_Meter aTOper ("TCollection_Array2 operator=",0);
128   ////////////////////////////////Perf_Meter aNAssi ("NCollection_Array2 Assign",0);
129   for (i=0; i<theRep; i++)
130     {
131       ////////////////////////////////aNCrea.Start();
132       PERF_START_METER("NCollection_Array2 creation")
133       ////////////////////////////////QANCollection_Array2 a1(1,theSize,1,theSize), a2(1,theSize,1,theSize);
134       QANCollection_Array2Perf a1(1,theSize,1,theSize), a2(1,theSize,1,theSize);
135       ////////////////////////////////aNCrea.Stop();
136       PERF_STOP_METER("NCollection_Array2 creation")
137       ////////////////////////////////aNFill.Start();
138       PERF_START_METER("NCollection_Array2 filling")
139       for (j=1; j<=theSize; j++)
140         for (k=1; k<=theSize; k++)
141           Random(a1(j,k));
142       ////////////////////////////////aNFill.Stop();
143       PERF_STOP_METER("NCollection_Array2 filling")
144       ////////////////////////////////aNFind.Start();
145       PERF_START_METER("NCollection_Array2 finding")
146       for (j=1; j<=theSize*theSize; j++)
147         {
148           Standard_Integer m,n;
149           Random(m,theSize);
150           Random(n,theSize);
151           a1.Value(m+1,n+1);
152         }
153       ////////////////////////////////aNFind.Stop();
154       PERF_STOP_METER("NCollection_Array2 finding")
155       ////////////////////////////////aNOper.Start();
156       PERF_START_METER("NCollection_Array2 operator=")
157       a2 = a1;
158       ////////////////////////////////aNOper.Stop();
159       PERF_STOP_METER("NCollection_Array2 operator=")
160       ////////////////////////////////aNAssi.Start();
161       PERF_START_METER("NCollection_Array2 Assign")
162       a2.Assign(a1);
163       ////////////////////////////////aNAssi.Stop();
164       PERF_STOP_METER("NCollection_Array2 Assign")
165     }
166
167   for (i=0; i<theRep; i++)
168     {
169       ////////////////////////////////aTCrea.Start();
170       PERF_START_METER("TCollection_Array2 creation")
171       TColgp_Array2OfPnt a1(1,theSize,1,theSize), a2(1,theSize,1,theSize);
172       ////////////////////////////////aTCrea.Stop();
173       PERF_STOP_METER("TCollection_Array2 creation")
174       ////////////////////////////////aTFill.Start();
175       PERF_START_METER("TCollection_Array2 filling")
176       for (j=1; j<=theSize; j++)
177         for (k=1; k<=theSize; k++)
178           Random(a1(j,k));
179       ////////////////////////////////aTFill.Stop();
180       PERF_STOP_METER("TCollection_Array2 filling")
181       ////////////////////////////////aTFind.Start();
182       PERF_START_METER("TCollection_Array2 finding")
183       for (j=1; j<=theSize*theSize; j++)
184         {
185           Standard_Integer m,n;
186           Random(m,theSize);
187           Random(n,theSize);
188           a1.Value(m+1,n+1);
189         }
190       ////////////////////////////////aTFind.Stop();
191       PERF_STOP_METER("TCollection_Array2 finding")
192       ////////////////////////////////aTOper.Start();
193       PERF_START_METER("TCollection_Array2 operator=")
194       a2 = a1;
195       ////////////////////////////////aTOper.Stop();
196       PERF_STOP_METER("TCollection_Array2 operator=")
197     }
198   PERF_PRINT_ALL
199 }
200
201
202 #endif