Return-Path: X-Original-To: apmail-maven-commits-archive@www.apache.org Delivered-To: apmail-maven-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 01E08E8B8 for ; Sun, 16 Dec 2012 16:35:41 +0000 (UTC) Received: (qmail 17790 invoked by uid 500); 16 Dec 2012 16:35:40 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 17600 invoked by uid 500); 16 Dec 2012 16:35:40 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 17552 invoked by uid 99); 16 Dec 2012 16:35:39 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Dec 2012 16:35:39 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 837C881D66C; Sun, 16 Dec 2012 16:35:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: krosenvold@apache.org To: commits@maven.apache.org X-Mailer: ASF-Git Admin Mailer Subject: git commit: o Removed unused code Message-Id: <20121216163538.837C881D66C@tyr.zones.apache.org> Date: Sun, 16 Dec 2012 16:35:38 +0000 (UTC) Updated Branches: refs/heads/master 5b56fe700 -> 38f1c75f9 o Removed unused code Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/38f1c75f Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/38f1c75f Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/38f1c75f Branch: refs/heads/master Commit: 38f1c75f9af70d49cc97ccc88db4e5341cf3cfdc Parents: 5b56fe7 Author: Kristian Rosenvold Authored: Sun Dec 16 17:35:18 2012 +0100 Committer: Kristian Rosenvold Committed: Sun Dec 16 17:35:18 2012 +0100 ---------------------------------------------------------------------- .../util/internal/FunkyTwoThreadBlockingQueue.java | 102 -------- .../util/internal/TwoThreadBlockingQueue.java | 104 -------- .../util/internal/TwoThreadBlockingQueueTest.java | 182 --------------- 3 files changed, 0 insertions(+), 388 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/38f1c75f/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/FunkyTwoThreadBlockingQueue.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/FunkyTwoThreadBlockingQueue.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/FunkyTwoThreadBlockingQueue.java deleted file mode 100644 index 2d619f6..0000000 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/FunkyTwoThreadBlockingQueue.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.maven.plugin.surefire.util.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * A producer/consumer queue that is optimized for *one* producer thread - * and *one* consumer thread, and solely optimized for efficient inserts - * by the producer, minimizing producer locking for hand-off to - * a second consumer. - *

- * TwoThreadBlockingQueue insert 5000000 elements in = 52 - * FunkyTwoThreadBlockingQueue insert 5000000 elements in = 42 - * TwoThreadBlockingQueue produced and taken 5000000 elements in = 104 - * LinkedBlockingQueue insert 5000000 elements in = 1815 - * LinkedBlockingDeque insert 5000000 elements in = 113 - * ArrayList insert 5000000 elements in = 18 - * LinkedList insert 5000000 elements in = 334 - *

- * Todo: Determine if this design actually works ;) - * - * @author Kristian Rosenvold - */ -public class FunkyTwoThreadBlockingQueue - implements BlockingQueue -{ - final int chunkSize = 100; - - private Chunk takeChunk = new Chunk(); - - private int takePos = 0; - - private Chunk insertChunk = takeChunk; - - private int insertPos = 0; - - private volatile boolean memoryModelGuard; - - - public void put( String object ) - { - insertChunk.elements[insertPos] = object; - if ( ++insertPos == chunkSize ) - { - Chunk newChunk = new Chunk(); - insertChunk.next = newChunk; - insertChunk = newChunk; - insertPos = 0; - } - memoryModelGuard = true; - } - - public void add( String object ) - { - put( object ); - } - - - public String take() - throws InterruptedException - { - if ( takePos >= chunkSize ) - { - takeChunk = takeChunk.next; - takePos = 0; - } - - boolean fud = memoryModelGuard; - String next = takeChunk.elements[takePos]; - while ( next == null ) - { - Thread.sleep( 1 ); - fud = memoryModelGuard; - next = takeChunk.elements[takePos]; - } - takePos++; - return next; - } - - final class Chunk - { - final String[] elements = new String[chunkSize]; - - volatile Chunk next; - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/38f1c75f/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/TwoThreadBlockingQueue.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/TwoThreadBlockingQueue.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/TwoThreadBlockingQueue.java deleted file mode 100644 index 0fa7a75..0000000 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/TwoThreadBlockingQueue.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.apache.maven.plugin.surefire.util.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * A producer/consumer queue that is optimized for *one* producer thread - * and *one* consumer thread, and solely optimized for efficient inserts - * by the producer, minimizing producer locking for hand-off to - * a second consumer. - *

- * The producer can actually come in on different threads - * (because lastInserted is volatile), but can/will lose - * items if they arrive concurrently. Take only supports a single - * client. - *

- * This runs like crazy, but is not the most garbage friendly around. - *

- * TwoThreadBlockingQueue insert 5000000 elements in = 52ms - * LinkedBlockingQueue insert 5000000 elements in = 179ms - * LikedBlockingDeque insert 5000000 elements in = 114ms - * ArrayList insert 5000000 elements in = 18ms (sized at correct size from start) - * - * @author Kristian Rosenvold - */ -public class TwoThreadBlockingQueue - implements BlockingQueue -{ - private volatile Element lastInserted; - - private volatile Element lastTaken; - - private volatile Element first; - - public static final String poison = "poison"; - - public void add( String object ) - { - Element next = new Element( object ); - if ( lastInserted == null ) - { - first = lastInserted = next; - } - else - { - lastInserted.next = next; - lastInserted = next; - } - } - - public String take() - throws InterruptedException - { - if ( lastTaken == null ) - { - while ( first == null ) - { - Thread.sleep( 1 ); - } - lastTaken = first; - first = null; - } - else - { - Element next = lastTaken.next; - while ( next == null ) - { - Thread.sleep( 1 ); - next = lastTaken.next; - } - lastTaken = next; - } - return lastTaken.object; - } - - private static class Element - { - private final String object; - - private volatile Element next; - - Element( String object ) - { - this.object = object; - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/38f1c75f/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java deleted file mode 100644 index ba70160..0000000 --- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java +++ /dev/null @@ -1,182 +0,0 @@ -package org.apache.maven.surefire.util.internal; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.FutureTask; -import java.util.concurrent.LinkedBlockingQueue; -import org.apache.maven.plugin.surefire.util.internal.BlockingQueue; -import org.apache.maven.plugin.surefire.util.internal.FunkyTwoThreadBlockingQueue; -import org.apache.maven.plugin.surefire.util.internal.TwoThreadBlockingQueue; - -import junit.framework.Assert; -import junit.framework.TestCase; - -/** - * @author Kristian Rosenvold - */ -public class TwoThreadBlockingQueueTest - extends TestCase -{ - final int num = 100000; - - public void testPut() - throws Exception - { - BlockingQueue twoThreadBlockingQueue = new TwoThreadBlockingQueue(); - - String[] items = generate( num ); - //long start = System.currentTimeMillis(); - for ( String item : items ) - { - twoThreadBlockingQueue.add( item ); - } - //long elapsed = System.currentTimeMillis() - start; - //System.out.println( "TwoThreadBlockingQueue insert " + num + " elements in = " + elapsed ); - System.gc(); - } - - public void testFunkyPut() - throws Exception - { - FunkyTwoThreadBlockingQueue twoThreadBlockingQueue = new FunkyTwoThreadBlockingQueue(); - - String[] items = generate( num ); - //long start = System.currentTimeMillis(); - for ( String item : items ) - { - twoThreadBlockingQueue.put( item ); - } - //long elapsed = System.currentTimeMillis() - start; - //System.out.println( "FunkyTwoThreadBlockingQueue insert " + num + " elements in = " + elapsed ); - System.gc(); - } - - - public void testPutAndTake() - throws Exception - { - final FunkyTwoThreadBlockingQueue twoThreadBlockingQueue = new FunkyTwoThreadBlockingQueue(); - - Callable consumer = new Callable() - { - public String call() - throws Exception - { - int num = 0; - String taken; - do - { - taken = twoThreadBlockingQueue.take(); - if ( taken != TwoThreadBlockingQueue.poison ) - { - Assert.assertEquals( "item" + num++, taken ); - } - } - while ( taken != TwoThreadBlockingQueue.poison ); - return taken; - } - }; - - FutureTask futureTask = new FutureTask( consumer ); - Thread thread = new Thread( futureTask ); - thread.start(); - - String[] items = generate( num ); - //long start = System.currentTimeMillis(); - for ( String item : items ) - { - twoThreadBlockingQueue.put( item ); - } - twoThreadBlockingQueue.put( TwoThreadBlockingQueue.poison ); - //long elapsed = System.currentTimeMillis() - start; - - futureTask.get(); - - // System.out.println( "TwoThreadBlockingQueue produced and taken " + num + " elements in = " + elapsed ); - System.gc(); - } - - public void testLBQPut() - throws Exception - { - LinkedBlockingQueue twoThreadBlockingQueue = new LinkedBlockingQueue(); - - String[] items = generate( num ); - //long start = System.currentTimeMillis(); - for ( String item : items ) - { - twoThreadBlockingQueue.put( item ); - } - //long elapsed = System.currentTimeMillis() - start; - //System.out.println( "LinkedBlockingQueue insert " + num + " elements in = " + elapsed ); - System.gc(); - } - - public void testArrayList() - throws Exception - { - List twoThreadBlockingQueue = new ArrayList( num ); - - String[] items = generate( num ); - //long start = System.currentTimeMillis(); - for ( String item : items ) - { - twoThreadBlockingQueue.add( item ); - } - //long elapsed = System.currentTimeMillis() - start; - //System.out.println( "ArrayList insert " + num + " elements in = " + elapsed ); - System.gc(); - } - - public void testLinkedList() - throws Exception - { - LinkedList twoThreadBlockingQueue = new LinkedList(); - - String[] items = generate( num ); - //long start = System.currentTimeMillis(); - for ( String item : items ) - { - twoThreadBlockingQueue.add( item ); - } - //long elapsed = System.currentTimeMillis() - start; - //System.out.println( "LinkedList insert " + num + " elements in = " + elapsed ); - System.gc(); - } - - public void testTake() - throws Exception - { - } - - String[] generate( int num ) - { - String[] result = new String[num]; - for ( int i = 0; i < num; i++ ) - { - result[i] = "item" + i; - } - return result; - } -}