r392 - trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform
Author: bleny Date: 2010-10-08 16:57:16 +0200 (Fri, 08 Oct 2010) New Revision: 392 Url: http://nuiton.org/repositories/revision/wikitty/392 Log: renaming non-test class to be ignored by test-runner Added: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceBenchMark.java Removed: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceTest.java Copied: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceBenchMark.java (from rev 391, trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceTest.java) =================================================================== --- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceBenchMark.java (rev 0) +++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceBenchMark.java 2010-10-08 14:57:16 UTC (rev 392) @@ -0,0 +1,97 @@ +/* *##% + * Copyright (c) 2009 ruchaud. All rights reserved. + * + * 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 3 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, see <http://www.gnu.org/licenses/>. + *##%*/ + +package org.nuiton.wikitty.conform; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Random; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.nuiton.wikitty.FieldType; +import org.nuiton.wikitty.Wikitty; +import org.nuiton.wikitty.WikittyExtension; +import org.nuiton.wikitty.WikittyImpl; +import org.nuiton.wikitty.WikittyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * This class is <strong>NOT</strong> a test. It's a benchlark that + * computes values and log them. This class is named properly to + * prevent any test Runner to run it. + * + * @author ruchaud + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations="classpath:META-INF/spring/wikitty-test.xml") +public class PerformanceBenchMark { + + protected final static Log log = LogFactory.getLog(PerformanceBenchMark.class); + + protected final static int WIKITTY_SIZE = 10000; + + @Autowired + protected WikittyService wikittyService; + + @Test + public void testPerformanceWikitty() throws Exception { + testPerformanceWikitty(3); + testPerformanceWikitty(50); + testPerformanceWikitty(100); + } + + protected void testPerformanceWikitty(int fieldSize) { + WikittyExtension extension = new WikittyExtension("Performance" + fieldSize); + for (int i = 0; i < fieldSize; i++) { + FieldType fieldType = new FieldType(FieldType.TYPE.STRING, 1, 1); + extension.addField("field" + i, fieldType); + } + wikittyService.storeExtension(null, extension); + + Collection<Wikitty> wikitties = new ArrayList<Wikitty>(WIKITTY_SIZE); + for (int i = 0; i < WIKITTY_SIZE; i++) { + Wikitty wikitty = new WikittyImpl("Performance" + fieldSize + "id" + i); + wikitty.addExtension(extension); + for (int j = 0; j < fieldSize; j++) { + wikitty.setField("Performance" + fieldSize, "field" + j, "value" + j); + } + wikitties.add(wikitty); + } + long start = System.currentTimeMillis(); + wikittyService.store(null, wikitties); + long end = System.currentTimeMillis(); + log.info("[Performance" + fieldSize + "] Write times : " + ((end - start) / 1000) + "s"); + + Random random = new Random(); + start = System.currentTimeMillis(); + for (int i = 0; i < WIKITTY_SIZE; i++) { + int nextInt = random.nextInt(WIKITTY_SIZE); + wikittyService.restore(null, "Performance" + fieldSize + "id" + nextInt); + } + end = System.currentTimeMillis(); + log.info("[Performance" + fieldSize + "] Read times : " + ((end - start) / 1000) + "s"); + } +} Property changes on: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceBenchMark.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Deleted: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceTest.java =================================================================== --- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceTest.java 2010-10-06 17:42:23 UTC (rev 391) +++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/conform/PerformanceTest.java 2010-10-08 14:57:16 UTC (rev 392) @@ -1,93 +0,0 @@ -/* *##% - * Copyright (c) 2009 ruchaud. All rights reserved. - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - *##%*/ - -package org.nuiton.wikitty.conform; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Random; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.nuiton.wikitty.FieldType; -import org.nuiton.wikitty.Wikitty; -import org.nuiton.wikitty.WikittyExtension; -import org.nuiton.wikitty.WikittyImpl; -import org.nuiton.wikitty.WikittyService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author ruchaud - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations="classpath:META-INF/spring/wikitty-test.xml") -public class PerformanceTest { - - protected final static Log log = LogFactory.getLog(PerformanceTest.class); - - protected final static int WIKITTY_SIZE = 10000; - - @Autowired - protected WikittyService wikittyService; - - @Test - public void testPerformanceWikitty() throws Exception { - testPerformanceWikitty(3); - testPerformanceWikitty(50); - testPerformanceWikitty(100); - } - - protected void testPerformanceWikitty(int fieldSize) { - WikittyExtension extension = new WikittyExtension("Performance" + fieldSize); - for (int i = 0; i < fieldSize; i++) { - FieldType fieldType = new FieldType(FieldType.TYPE.STRING, 1, 1); - extension.addField("field" + i, fieldType); - } - wikittyService.storeExtension(null, extension); - - Collection<Wikitty> wikitties = new ArrayList<Wikitty>(WIKITTY_SIZE); - for (int i = 0; i < WIKITTY_SIZE; i++) { - Wikitty wikitty = new WikittyImpl("Performance" + fieldSize + "id" + i); - wikitty.addExtension(extension); - for (int j = 0; j < fieldSize; j++) { - wikitty.setField("Performance" + fieldSize, "field" + j, "value" + j); - } - wikitties.add(wikitty); - } - long start = System.currentTimeMillis(); - wikittyService.store(null, wikitties); - long end = System.currentTimeMillis(); - log.info("[Performance" + fieldSize + "] Write times : " + ((end - start) / 1000) + "s"); - - Random random = new Random(); - start = System.currentTimeMillis(); - for (int i = 0; i < WIKITTY_SIZE; i++) { - int nextInt = random.nextInt(WIKITTY_SIZE); - wikittyService.restore(null, "Performance" + fieldSize + "id" + nextInt); - } - end = System.currentTimeMillis(); - log.info("[Performance" + fieldSize + "] Read times : " + ((end - start) / 1000) + "s"); - } -}
participants (1)
-
bleny@users.nuiton.org