7fd59977 |
1 | // File: tests.cxx |
2 | // Created: 16.04.02 10:55:25 |
3 | // Author: Alexander GRIGORIEV |
4 | // Copyright: Open Cascade 2002 |
5 | |
6 | #include <TColgp_Array1OfPnt.hxx> |
7 | #include <TColgp_SequenceOfPnt.hxx> |
8 | |
9 | #define USE_MACROS |
10 | #ifdef USE_MACROS |
11 | #include <NCollection_DefineArray1.hxx> |
12 | #include <NCollection_DefineSequence.hxx> |
13 | DEFINE_BASECOLLECTION (MyBaseCollPnt, gp_Pnt) |
14 | DEFINE_ARRAY1 (MyArray1, MyBaseCollPnt, gp_Pnt) |
15 | DEFINE_SEQUENCE (MySequence, MyBaseCollPnt, gp_Pnt) |
16 | #else |
17 | #include <NCollection_Sequence.hxx> |
18 | #include <NCollection_Array1.hxx> |
19 | typedef NCollection_Array1<gp_Pnt> MyArray1; |
20 | typedef NCollection_Sequence<gp_Pnt> MySequence; |
21 | typedef NCollection_BaseCollection<gp_Pnt> MyBaseCollPnt; |
22 | #endif |
23 | |
24 | #define PERF_ENABLE_METERS |
25 | #include <DebugTools.h> |
26 | //////////////#include <Perf_Meter.hxx> |
27 | |
28 | extern Handle(NCollection_BaseAllocator) getAlloc (const int i); |
29 | |
30 | const Standard_Integer REPEAT = 100; |
31 | |
32 | void createArray (TColgp_Array1OfPnt& anArrPnt) |
33 | { |
34 | for (Standard_Integer j = 0; j < 2*REPEAT; j++) { |
35 | PERF_START_METER("Create array") |
36 | for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++) |
37 | anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2)); |
38 | PERF_STOP_METER("Create array") |
39 | } |
40 | } |
41 | |
42 | void createArray (MyArray1& anArrPnt) |
43 | { |
44 | for (Standard_Integer j = 0; j < 2*REPEAT; j++) { |
45 | PERF_START_METER("Create array") |
46 | for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++) |
47 | anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2)); |
48 | PERF_STOP_METER("Create array") |
49 | } |
50 | } |
51 | |
52 | void assignArray (TColgp_Array1OfPnt& aDest, const TColgp_Array1OfPnt& aSrc) |
53 | { |
54 | for (Standard_Integer i = 0; i < 2*REPEAT; i++) { |
55 | PERF_START_METER("Assign array to array") |
56 | aDest = aSrc; |
57 | PERF_STOP_METER("Assign array to array") |
58 | } |
59 | } |
60 | |
61 | void assignCollection (MyBaseCollPnt& aDest, |
62 | const MyBaseCollPnt& aSrc, |
63 | const char * MeterName) |
64 | { |
65 | for (Standard_Integer i = 0; i < REPEAT; i++) { |
66 | perf_start_meter (MeterName); |
67 | // if (getAlloc(1).IsNull() == Standard_False) |
68 | // if (getAlloc(1)->IsKind(STANDARD_TYPE(NCollection_IncAllocator))) |
69 | // Handle(NCollection_IncAllocator)::DownCast(getAlloc(1)) -> Clean(); |
70 | aDest.Assign(aSrc); |
71 | perf_stop_meter (MeterName); |
72 | } |
73 | } |
74 | |
75 | void assignArray (MyArray1& aDest, |
76 | const MyArray1& aSrc) |
77 | { |
78 | for (Standard_Integer i = 0; i < 2*REPEAT; i++) { |
79 | PERF_START_METER("Assign array to array") |
80 | aDest = aSrc; |
81 | PERF_STOP_METER("Assign array to array") |
82 | } |
83 | } |
84 | |
85 | void createSequence (TColgp_SequenceOfPnt& aSeq) |
86 | { |
87 | for (Standard_Integer j = 0; j < REPEAT; j++) { |
88 | PERF_START_METER("Clear sequence") |
89 | aSeq.Clear(); |
90 | PERF_STOP_METER("Clear sequence") |
91 | PERF_START_METER("Create sequence") |
92 | for (Standard_Integer i = 0; i < 100000; i++) |
93 | aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2))); |
94 | PERF_STOP_METER("Create sequence") |
95 | } |
96 | } |
97 | |
98 | void createSequence (MySequence& aSeq) |
99 | { |
100 | for (Standard_Integer j = 0; j < REPEAT; j++) { |
101 | PERF_START_METER("Clear sequence") |
102 | aSeq.Clear(); |
103 | // if (getAlloc(0).IsNull() == Standard_False) |
104 | // if (getAlloc(0)->IsKind(STANDARD_TYPE(NCollection_IncAllocator))) |
105 | // Handle(NCollection_IncAllocator)::DownCast(getAlloc(0)) -> Clean(); |
106 | PERF_STOP_METER("Clear sequence") |
107 | PERF_START_METER("Create sequence") |
108 | for (Standard_Integer i = 0; i < 100000; i++) |
109 | aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2))); |
110 | PERF_STOP_METER("Create sequence") |
111 | } |
112 | } |
113 | |
114 | void assignSequence (TColgp_SequenceOfPnt& aDest, |
115 | const TColgp_SequenceOfPnt& aSrc) |
116 | { |
117 | for (Standard_Integer i = 0; i < REPEAT; i++) { |
118 | PERF_START_METER("Assign sequence to sequence") |
119 | aDest = aSrc; |
120 | PERF_STOP_METER("Assign sequence to sequence") |
121 | } |
122 | } |
123 | |
124 | void assignSequence (MySequence& aDest, const MySequence& aSrc) |
125 | { |
126 | for (Standard_Integer i = 0; i < REPEAT; i++) { |
127 | PERF_START_METER("Assign sequence to sequence") |
128 | // if (getAlloc(1).IsNull() == Standard_False) |
129 | // if (getAlloc(1)->IsKind(STANDARD_TYPE(NCollection_IncAllocator))) |
130 | // Handle(NCollection_IncAllocator)::DownCast(getAlloc(1)) -> Clean(); |
131 | aDest = aSrc; |
132 | PERF_STOP_METER("Assign sequence to sequence") |
133 | } |
134 | } |
135 | |
136 | void printAllMeters () |
137 | { |
138 | PERF_PRINT_ALL_METERS |
139 | } |