1 // Created on: 2002-04-16
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
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.
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.
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.
21 #include <TColgp_Array1OfPnt.hxx>
22 #include <TColgp_SequenceOfPnt.hxx>
26 #include <NCollection_DefineArray1.hxx>
27 #include <NCollection_DefineSequence.hxx>
28 DEFINE_BASECOLLECTION (MyBaseCollPnt, gp_Pnt)
29 DEFINE_ARRAY1 (MyArray1, MyBaseCollPnt, gp_Pnt)
30 DEFINE_SEQUENCE (MySequence, MyBaseCollPnt, gp_Pnt)
32 #include <NCollection_Sequence.hxx>
33 #include <NCollection_Array1.hxx>
34 typedef NCollection_Array1<gp_Pnt> MyArray1;
35 typedef NCollection_Sequence<gp_Pnt> MySequence;
36 typedef NCollection_BaseCollection<gp_Pnt> MyBaseCollPnt;
39 #define PERF_ENABLE_METERS
40 #include <DebugTools.h>
41 //////////////#include <Perf_Meter.hxx>
43 extern Handle(NCollection_BaseAllocator) getAlloc (const int i);
45 const Standard_Integer REPEAT = 100;
47 void createArray (TColgp_Array1OfPnt& anArrPnt)
49 for (Standard_Integer j = 0; j < 2*REPEAT; j++) {
50 PERF_START_METER("Create array")
51 for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++)
52 anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2));
53 PERF_STOP_METER("Create array")
57 void createArray (MyArray1& anArrPnt)
59 for (Standard_Integer j = 0; j < 2*REPEAT; j++) {
60 PERF_START_METER("Create array")
61 for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++)
62 anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2));
63 PERF_STOP_METER("Create array")
67 void assignArray (TColgp_Array1OfPnt& aDest, const TColgp_Array1OfPnt& aSrc)
69 for (Standard_Integer i = 0; i < 2*REPEAT; i++) {
70 PERF_START_METER("Assign array to array")
72 PERF_STOP_METER("Assign array to array")
76 void assignCollection (MyBaseCollPnt& aDest,
77 const MyBaseCollPnt& aSrc,
78 const char * MeterName)
80 for (Standard_Integer i = 0; i < REPEAT; i++) {
81 perf_start_meter (MeterName);
82 // if (getAlloc(1).IsNull() == Standard_False)
83 // if (getAlloc(1)->IsKind(STANDARD_TYPE(NCollection_IncAllocator)))
84 // Handle(NCollection_IncAllocator)::DownCast(getAlloc(1)) -> Clean();
86 perf_stop_meter (MeterName);
90 void assignArray (MyArray1& aDest,
93 for (Standard_Integer i = 0; i < 2*REPEAT; i++) {
94 PERF_START_METER("Assign array to array")
96 PERF_STOP_METER("Assign array to array")
100 void createSequence (TColgp_SequenceOfPnt& aSeq)
102 for (Standard_Integer j = 0; j < REPEAT; j++) {
103 PERF_START_METER("Clear sequence")
105 PERF_STOP_METER("Clear sequence")
106 PERF_START_METER("Create sequence")
107 for (Standard_Integer i = 0; i < 100000; i++)
108 aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2)));
109 PERF_STOP_METER("Create sequence")
113 void createSequence (MySequence& aSeq)
115 for (Standard_Integer j = 0; j < REPEAT; j++) {
116 PERF_START_METER("Clear sequence")
118 // if (getAlloc(0).IsNull() == Standard_False)
119 // if (getAlloc(0)->IsKind(STANDARD_TYPE(NCollection_IncAllocator)))
120 // Handle(NCollection_IncAllocator)::DownCast(getAlloc(0)) -> Clean();
121 PERF_STOP_METER("Clear sequence")
122 PERF_START_METER("Create sequence")
123 for (Standard_Integer i = 0; i < 100000; i++)
124 aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2)));
125 PERF_STOP_METER("Create sequence")
129 void assignSequence (TColgp_SequenceOfPnt& aDest,
130 const TColgp_SequenceOfPnt& aSrc)
132 for (Standard_Integer i = 0; i < REPEAT; i++) {
133 PERF_START_METER("Assign sequence to sequence")
135 PERF_STOP_METER("Assign sequence to sequence")
139 void assignSequence (MySequence& aDest, const MySequence& aSrc)
141 for (Standard_Integer i = 0; i < REPEAT; i++) {
142 PERF_START_METER("Assign sequence to sequence")
143 // if (getAlloc(1).IsNull() == Standard_False)
144 // if (getAlloc(1)->IsKind(STANDARD_TYPE(NCollection_IncAllocator)))
145 // Handle(NCollection_IncAllocator)::DownCast(getAlloc(1)) -> Clean();
147 PERF_STOP_METER("Assign sequence to sequence")
151 void printAllMeters ()
153 PERF_PRINT_ALL_METERS