From 16c715ceec5064432dba4485e51df6ca8334a049 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 8 Dec 2009 09:42:38 +0100 Subject: [PATCH] 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 --- applications/test/PackedList3/Make/files | 3 + applications/test/PackedList3/Make/options | 0 .../test/PackedList3/PackedListTest3.C | 75 +++++++++++++++++++ .../containers/Lists/PackedList/PackedListI.H | 11 ++- 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 applications/test/PackedList3/Make/files create mode 100644 applications/test/PackedList3/Make/options create mode 100644 applications/test/PackedList3/PackedListTest3.C diff --git a/applications/test/PackedList3/Make/files b/applications/test/PackedList3/Make/files new file mode 100644 index 0000000000..0e119bc4f3 --- /dev/null +++ b/applications/test/PackedList3/Make/files @@ -0,0 +1,3 @@ +PackedListTest3.C + +EXE = $(FOAM_USER_APPBIN)/PackedListTest3 diff --git a/applications/test/PackedList3/Make/options b/applications/test/PackedList3/Make/options new file mode 100644 index 0000000000..e69de29bb2 diff --git a/applications/test/PackedList3/PackedListTest3.C b/applications/test/PackedList3/PackedListTest3.C new file mode 100644 index 0000000000..9b5b60a118 --- /dev/null +++ b/applications/test/PackedList3/PackedListTest3.C @@ -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 +#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" + <::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 + ); } }