Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2002-05-15 |
2 | // Created by: Alexander KARTOMIN (akm) | |
973c2be1 | 3 | // Copyright (c) 2002-2014 OPEN CASCADE SAS |
b311480e | 4 | // |
973c2be1 | 5 | // This file is part of Open CASCADE Technology software library. |
b311480e | 6 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 12 | // |
973c2be1 | 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. | |
ba39a6a3 Y |
15 | |
16 | #ifndef QANCollection_PerfSparseArray_HeaderFile | |
17 | #define QANCollection_PerfSparseArray_HeaderFile | |
18 | ||
19 | #define PERF_ENABLE_METERS | |
c2ae831c | 20 | #include <OSD_PerfMeter.hxx> |
ba39a6a3 Y |
21 | ////////////////////////////////#include <Perf_Meter.hxx> |
22 | #include <NCollection_SparseArray.hxx> | |
23 | #include <NCollection_SparseArrayBase.hxx> | |
24 | ||
25 | // ===================== Test perform of SparseArray type ========================== | |
26 | void CompSparseArray (const Standard_Integer theRep, const Standard_Integer theSize) | |
27 | { | |
28 | Standard_Integer i,j; | |
29 | for (i=0; i<theRep; i++) | |
30 | { | |
31 | PERF_START_METER("NCollection_SparseArray creation") | |
32 | ||
33 | NCollection_SparseArray<Standard_Integer> a1(theSize),a2(theSize); | |
34 | ||
35 | PERF_STOP_METER("NCollection_SparseArray creation") | |
36 | ||
37 | PERF_START_METER("NCollection_SparseArray filling") | |
38 | for( j=0;j<theSize;j++ ) | |
39 | { | |
40 | Standard_Integer iIndex; | |
41 | Random(iIndex,theSize); | |
42 | a1.SetValue(j,iIndex+1); | |
43 | } | |
44 | ||
45 | PERF_STOP_METER("NCollection_SparseArray filling") | |
46 | ||
47 | PERF_START_METER("NCollection_SparseArray size") | |
7dc9e047 | 48 | Standard_Size sizeSparseArray=a1.Size(); |
49 | (void)sizeSparseArray; // avoid compiler warning on unused variable | |
ba39a6a3 Y |
50 | PERF_STOP_METER("NCollection_SparseArray size") |
51 | ||
52 | PERF_START_METER("NCollection_Array1 Assign") | |
53 | a2.Assign(a1); | |
54 | PERF_STOP_METER("NCollection_Array1 Assign") | |
55 | PERF_START_METER("NCollection_SparseArray HasValue") | |
56 | for (j=0; j<theSize; j++) | |
57 | { | |
58 | Standard_Integer iIndex; | |
59 | Random(iIndex,theSize); | |
60 | a2.HasValue(iIndex+1); | |
61 | } | |
62 | PERF_STOP_METER("NCollection_SparseArray HasValue") | |
63 | PERF_START_METER("NCollection_SparseArray UnsetValue") | |
64 | for (j=0; j<theSize; j++) | |
65 | { | |
66 | Standard_Integer iIndex; | |
67 | Random(iIndex,theSize); | |
68 | a1.UnsetValue(iIndex+1); | |
69 | } | |
70 | PERF_STOP_METER("NCollection_SparseArray UnsetValue") | |
71 | ||
72 | PERF_START_METER("NCollection_SparseArray Clear") | |
73 | a1.Clear(); | |
74 | a2.Clear(); | |
75 | PERF_STOP_METER("NCollection_SparseArray Clear") | |
76 | ||
77 | } | |
78 | ||
c2ae831c | 79 | PERF_PRINT_ALL |
ba39a6a3 Y |
80 | } |
81 | ||
82 | #endif |