1 // Created on: 2002-04-16
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <TColgp_Array1OfPnt.hxx>
17 #include <TColgp_SequenceOfPnt.hxx>
21 #include <NCollection_DefineArray1.hxx>
22 #include <NCollection_DefineSequence.hxx>
23 DEFINE_BASECOLLECTION (MyBaseCollPnt, gp_Pnt)
24 DEFINE_ARRAY1 (MyArray1, MyBaseCollPnt, gp_Pnt)
25 DEFINE_SEQUENCE (MySequence, MyBaseCollPnt, gp_Pnt)
27 #include <NCollection_Sequence.hxx>
28 #include <NCollection_Array1.hxx>
29 typedef NCollection_Array1<gp_Pnt> MyArray1;
30 typedef NCollection_Sequence<gp_Pnt> MySequence;
31 typedef NCollection_BaseCollection<gp_Pnt> MyBaseCollPnt;
34 #define PERF_ENABLE_METERS
35 #include <OSD_PerfMeter.hxx>
37 extern Handle(NCollection_BaseAllocator) getAlloc (const int i);
39 const Standard_Integer REPEAT = 100;
41 void createArray (TColgp_Array1OfPnt& anArrPnt)
43 OSD_PerfMeter aPerfMeter("Create array");
45 for (Standard_Integer j = 0; j < 2*REPEAT; j++) {
46 PERF_START_METER("Create array")
47 for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++)
48 anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2));
49 PERF_STOP_METER("Create array")
53 void createArray (MyArray1& anArrPnt)
55 for (Standard_Integer j = 0; j < 2*REPEAT; j++) {
56 PERF_START_METER("Create array")
57 for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++)
58 anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2));
59 PERF_STOP_METER("Create array")
63 void assignArray (TColgp_Array1OfPnt& aDest, const TColgp_Array1OfPnt& aSrc)
65 for (Standard_Integer i = 0; i < 2*REPEAT; i++) {
66 PERF_START_METER("Assign array to array")
68 PERF_STOP_METER("Assign array to array")
72 void assignCollection (MyBaseCollPnt& aDest,
73 const MyBaseCollPnt& aSrc,
74 const char * MeterName)
76 for (Standard_Integer i = 0; i < REPEAT; i++) {
77 perf_start_meter (MeterName);
78 // if (getAlloc(1).IsNull() == Standard_False)
79 // if (getAlloc(1)->IsKind(STANDARD_TYPE(NCollection_IncAllocator)))
80 // Handle(NCollection_IncAllocator)::DownCast(getAlloc(1)) -> Clean();
82 perf_stop_meter (MeterName);
86 void assignArray (MyArray1& aDest,
89 for (Standard_Integer i = 0; i < 2*REPEAT; i++) {
90 PERF_START_METER("Assign array to array")
92 PERF_STOP_METER("Assign array to array")
96 void createSequence (TColgp_SequenceOfPnt& aSeq)
98 for (Standard_Integer j = 0; j < REPEAT; j++) {
99 PERF_START_METER("Clear sequence")
101 PERF_STOP_METER("Clear sequence")
102 PERF_START_METER("Create sequence")
103 for (Standard_Integer i = 0; i < 100000; i++)
104 aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2)));
105 PERF_STOP_METER("Create sequence")
109 void createSequence (MySequence& aSeq)
111 for (Standard_Integer j = 0; j < REPEAT; j++) {
112 PERF_START_METER("Clear sequence")
114 // if (getAlloc(0).IsNull() == Standard_False)
115 // if (getAlloc(0)->IsKind(STANDARD_TYPE(NCollection_IncAllocator)))
116 // Handle(NCollection_IncAllocator)::DownCast(getAlloc(0)) -> Clean();
117 PERF_STOP_METER("Clear sequence")
118 PERF_START_METER("Create sequence")
119 for (Standard_Integer i = 0; i < 100000; i++)
120 aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2)));
121 PERF_STOP_METER("Create sequence")
125 void assignSequence (TColgp_SequenceOfPnt& aDest,
126 const TColgp_SequenceOfPnt& aSrc)
128 for (Standard_Integer i = 0; i < REPEAT; i++) {
129 PERF_START_METER("Assign sequence to sequence")
131 PERF_STOP_METER("Assign sequence to sequence")
135 void assignSequence (MySequence& aDest, const MySequence& aSrc)
137 for (Standard_Integer i = 0; i < REPEAT; i++) {
138 PERF_START_METER("Assign sequence to sequence")
139 // if (getAlloc(1).IsNull() == Standard_False)
140 // if (getAlloc(1)->IsKind(STANDARD_TYPE(NCollection_IncAllocator)))
141 // Handle(NCollection_IncAllocator)::DownCast(getAlloc(1)) -> Clean();
143 PERF_STOP_METER("Assign sequence to sequence")
147 void printAllMeters ()