From 7e8f6b7fd1c7046edde296e13d23af1c314fd44c Mon Sep 17 00:00:00 2001 From: Ramkumar Aiyengar Date: Sat, 14 Mar 2015 21:58:26 +0000 Subject: [PATCH] SOLR-6275: Remove nanoTime speed test git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1666754 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/org/apache/solr/util/TestUtils.java | 47 ------------------- 1 file changed, 47 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/util/TestUtils.java b/solr/core/src/test/org/apache/solr/util/TestUtils.java index 5b56a5b1fde..e144d21b323 100644 --- a/solr/core/src/test/org/apache/solr/util/TestUtils.java +++ b/solr/core/src/test/org/apache/solr/util/TestUtils.java @@ -18,23 +18,15 @@ package org.apache.solr.util; import java.util.Arrays; -import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; import org.apache.solr.SolrTestCaseJ4; -import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.SimpleOrderedMap; import org.apache.solr.common.util.StrUtils; import org.junit.Assert; -import org.junit.Test; /** * @@ -162,43 +154,4 @@ public class TestUtils extends SolrTestCaseJ4 { assertEquals( num, NumberUtils.SortableStr2long(sortable, 0, sortable.length() ) ); assertEquals( Long.toString(num), NumberUtils.SortableStr2long(sortable) ); } - - @Test - public void testNanoTimeSpeed() - { - final int maxNumThreads = 100; - final int numIters = 1000; - if (VERBOSE) log.info("testNanoTime: maxNumThreads = {}, numIters = {}", maxNumThreads, numIters); - - final ExecutorService workers = Executors.newCachedThreadPool(new DefaultSolrThreadFactory("nanoTimeTestThread")); - - for (int numThreads = 1; numThreads <= maxNumThreads; numThreads++) { - List> tasks = new ArrayList<> (); - for (int i = 0; i < numThreads; i ++) { - tasks.add(new Callable() { - @Override - public Long call() { - final long startTime = System.nanoTime(); - for (int i = 0; i < numIters; i++) { - System.nanoTime(); - } - return System.nanoTime() - startTime; - } - }); - } - - try { - List> results = workers.invokeAll(tasks); - long totalTime = 0; - for (Future res : results) { - totalTime += res.get(); - } - long timePerIter = totalTime / (numIters * numThreads); - assertTrue("Time taken for System.nanoTime is too high", timePerIter < 10000); - if (VERBOSE) log.info("numThreads = {}, time_per_call = {}ns", numThreads, timePerIter); - } catch (InterruptedException | ExecutionException ignored) {} - } - - ExecutorUtil.shutdownAndAwaitTermination(workers); - } }