Index: lutinmatrix/src/test/org/codelutin/math/matrix/PerfTest.java diff -u /dev/null lutinmatrix/src/test/org/codelutin/math/matrix/PerfTest.java:1.1 --- /dev/null Mon Apr 2 10:52:24 2007 +++ lutinmatrix/src/test/org/codelutin/math/matrix/PerfTest.java Mon Apr 2 10:52:19 2007 @@ -0,0 +1,435 @@ +/* *##% + * Copyright (C) 2006 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * PerfTest.java + * + * Created: 7 sept. 06 02:28:51 + * + * @author poussin + * @version $Revision: 1.1 $ + * + * Last update: $Date: 2007/04/02 10:52:19 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.math.matrix; + +import java.util.ArrayList; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.commons.lang.time.DurationFormatUtils; + + +/** + * @author poussin + * + */ + +public class PerfTest extends TestCase { + + static char CMAX = 'j'; + static int MAX = 10; + + public void testDoubleVectorIterator() throws Exception { + List sem = new ArrayList(); + for (char c='a'; c<=CMAX; c++) { + for (int i=1; i<=MAX; i++) { + sem.add(c + " " + i); + } + } + + MatrixND mat = null; + + // [ 2600 x 2600 x 2600 ] + long timestart = System.nanoTime(); + mat = MatrixFactory.getInstance(DoubleVector.class).create("Ma mat", new List[]{sem, sem, sem}); + long timeinit = System.nanoTime(); + // parcours avec iterator + long cpt = 1; + for (MatrixIterator i=mat.iterator(); i.hasNext();) { + i.next(); + i.setValue(cpt++); + } + long timeend = System.nanoTime(); + + System.out.println("Iterator DoubleVector init: " + DurationFormatUtils.formatDuration((timeinit-timestart)/1000000, "s'.'S") + + " fill: " + DurationFormatUtils.formatDuration((timeend-timeinit)/1000000, "s'.'S") ); + } + + public void testDoubleVectorIndex() throws Exception { + List sem = new ArrayList(); + for (char c='a'; c<=CMAX; c++) { + for (int i=1; i<=MAX; i++) { + sem.add(c + " " + i); + } + } + int size = sem.size(); + + MatrixND mat = null; + + // [ 2600 x 2600 x 2600 ] + long timestart = System.nanoTime(); + mat = MatrixFactory.getInstance(DoubleVector.class).create("Ma mat", new List[]{sem, sem, sem}); + long timeinit = System.nanoTime(); + // parcours avec iterator + long cpt = 1; + for (int x=0; x sem = new ArrayList(); + for (char c='a'; c<=CMAX; c++) { + for (int i=1; i<=MAX; i++) { + sem.add(c + " " + i); + } + } + int size = sem.size(); + + MatrixND mat = null; + + // [ 2600 x 2600 x 2600 ] + long timestart = System.nanoTime(); + mat = MatrixFactory.getInstance(DoubleVector.class).create("Ma mat", new List[]{sem, sem, sem}); + long timeinit = System.nanoTime(); + // parcours avec iterator + long cpt = 1; + for (int x=0; x sem = new ArrayList(); + for (char c='a'; c<=CMAX; c++) { + for (int i=1; i<=MAX; i++) { + sem.add(c + " " + i); + } + } + int size = sem.size(); + + MatrixND mat = null; + + // [ 2600 x 2600 x 2600 ] + long timestart = System.nanoTime(); + mat = MatrixFactory.getInstance(DoubleBigVector.class).create("Ma mat", new List[]{sem, sem, sem}); + long timeinit = System.nanoTime(); + // parcours avec iterator + long cpt = 1; + for (int x=0; x sem = new ArrayList(); + for (char c='a'; c<=CMAX; c++) { + for (int i=1; i<=MAX; i++) { + sem.add(c + " " + i); + } + } + int size = sem.size(); + + MatrixND mat = null; + + // [ 2600 x 2600 x 2600 ] + long timestart = System.nanoTime(); + mat = MatrixFactory.getInstance(FloatVector.class).create("Ma mat", new List[]{sem, sem, sem}); + long timeinit = System.nanoTime(); + // parcours avec iterator + long cpt = 1; + for (int x=0; x sem = new ArrayList(); + for (char c='a'; c<=CMAX; c++) { + for (int i=1; i<=MAX; i++) { + sem.add(c + " " + i); + } + } + int size = sem.size(); + + MatrixND mat = null; + + // [ 2600 x 2600 x 2600 ] + long timestart = System.nanoTime(); + mat = MatrixFactory.getInstance(FloatBigVector.class).create("Ma mat", new List[]{sem, sem, sem}); + long timeinit = System.nanoTime(); + // parcours avec iterator + long cpt = 1; + for (int x=0; x