Test-PackedList3.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25 
26 Description
27 
28 \*---------------------------------------------------------------------------*/
29 
30 #include "argList.H"
31 #include "boolList.H"
32 #include "HashSet.H"
33 #include "StaticHashTable.H"
34 #include "cpuTime.H"
35 #include <vector>
36 #include "PackedBoolList.H"
37 
38 using namespace Foam;
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 
43 // Main program:
44 
45 int main(int argc, char *argv[])
46 {
47  const label n = 100000000;
48  const label nReport = 1000000;
49 
50  cpuTime timer;
51 
52  // test inserts
53  // PackedBoolList
54  PackedBoolList packed;
55  for (label i = 0; i < n; i++)
56  {
57  if ((i % nReport) == 0 && i)
58  {
59  Info<< "i:" << i << " in " << timer.cpuTimeIncrement() << " s"
60  <<endl;
61  }
62  packed[i] = 1;
63  }
64  Info<< "insert test: " << n << " elements in "
65  << timer.cpuTimeIncrement() << " s\n\n";
66 
67  Info << "\nEnd\n" << endl;
68 
69  return 0;
70 }
71 
72 
73 // ************************************************************************* //
Foam::cpuTime
Starts timing CPU usage and return elapsed time from start.
Definition: cpuTime.H:52
Foam::PackedBoolList
A bit-packed bool list.
Definition: PackedBoolList.H:63
boolList.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
StaticHashTable.H
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Info
messageStream Info
PackedBoolList.H
argList.H
HashSet.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
cpuTime.H
Foam::timer
Implements a timeout mechanism via sigalarm.
Definition: timer.H:81
main
int main(int argc, char *argv[])
Definition: Test-PackedList3.C:42