mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Applied Mattijs' PackedList improvements
- resize with factor 2 as per DynamicList
Old insertion speed:
1000000 in 0.61 s
2000000 in 2.24 s
3000000 in 3.97 s
4000000 in 5.76 s
5000000 in 7.54 s
6000000 in 9.41 s
7000000 in 11.5 s
New insertion speed:
1000000 in 0.01 s
2000000 in 0.02 s
3000000 in 0.01 s
4000000 in 0.02 s
5000000 in 0.01 s
6000000 in 0.01 s
7000000 in 0.01 s
This commit is contained in:
3
applications/test/PackedList3/Make/files
Normal file
3
applications/test/PackedList3/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
PackedListTest3.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/PackedListTest3
|
||||
0
applications/test/PackedList3/Make/options
Normal file
0
applications/test/PackedList3/Make/options
Normal file
75
applications/test/PackedList3/PackedListTest3.C
Normal file
75
applications/test/PackedList3/PackedListTest3.C
Normal file
@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Application
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "boolList.H"
|
||||
#include "HashSet.H"
|
||||
#include "StaticHashTable.H"
|
||||
#include "cpuTime.H"
|
||||
#include <vector>
|
||||
#include "PackedList.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const label n = 100000000;
|
||||
const label nReport = 1000000;
|
||||
|
||||
cpuTime timer;
|
||||
|
||||
// test inserts
|
||||
// PackedBoolList
|
||||
PackedBoolList packed;
|
||||
for (label i = 0; i < n; i++)
|
||||
{
|
||||
if ((i % nReport) == 0 && i)
|
||||
{
|
||||
Info<< "i:" << i << " in " << timer.cpuTimeIncrement() << " s"
|
||||
<<endl;
|
||||
}
|
||||
packed[i] = 1;
|
||||
}
|
||||
Info<< "insert test: " << n << " elements in "
|
||||
<< timer.cpuTimeIncrement() << " s\n\n";
|
||||
|
||||
Info << "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -670,7 +670,16 @@ inline void Foam::PackedList<nBits>::reserve
|
||||
// need more capacity?
|
||||
if (len > StorageList::size())
|
||||
{
|
||||
StorageList::setSize(len, 0u);
|
||||
// Like DynamicList with SizeInc=0, SizeMult=2, SizeDiv=1
|
||||
StorageList::setSize
|
||||
(
|
||||
max
|
||||
(
|
||||
len,
|
||||
StorageList::size()*2
|
||||
),
|
||||
0u
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user