SOLR-6275: Remove nanoTime speed test

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1666754 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ramkumar Aiyengar 2015-03-14 21:58:26 +00:00
parent 24b20a53ff
commit 7e8f6b7fd1
1 changed files with 0 additions and 47 deletions

View File

@ -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<Callable<Long>> tasks = new ArrayList<> ();
for (int i = 0; i < numThreads; i ++) {
tasks.add(new Callable<Long>() {
@Override
public Long call() {
final long startTime = System.nanoTime();
for (int i = 0; i < numIters; i++) {
System.nanoTime();
}
return System.nanoTime() - startTime;
}
});
}
try {
List<Future<Long>> results = workers.invokeAll(tasks);
long totalTime = 0;
for (Future<Long> 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);
}
}