Commit 16c715ce authored by Mark Olesen's avatar Mark Olesen
Browse files

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
parent 8227aee6
PackedListTest3.C
EXE = $(FOAM_USER_APPBIN)/PackedListTest3
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment