use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class TestIndexingPerformance method testIndexingPerf.
public void testIndexingPerf() throws IOException {
int iter = 1000;
String iterS = System.getProperty("iter");
if (iterS != null)
iter = Integer.parseInt(iterS);
boolean overwrite = Boolean.parseBoolean(System.getProperty("overwrite", "false"));
String doc = System.getProperty("doc");
if (doc != null) {
StrUtils.splitSmart(doc, ",", true);
}
SolrQueryRequest req = lrf.makeRequest();
UpdateHandler updateHandler = req.getCore().getUpdateHandler();
String field = "textgap";
String[] fields = { field, "simple", field, "test", field, "how now brown cow", field, "what's that?", field, "radical!", field, "what's all this about, anyway?", field, "just how fast is this text indexing?" };
/***
String[] fields = {
"a_i","1"
,"b_i","2"
,"c_i","3"
,"d_i","4"
,"e_i","5"
,"f_i","6"
,"g_i","7"
,"h_i","8"
,"i_i","9"
,"j_i","0"
,"k_i","0"
};
***/
final RTimer timer = new RTimer();
AddUpdateCommand add = new AddUpdateCommand(req);
add.overwrite = overwrite;
for (int i = 0; i < iter; i++) {
add.clear();
add.solrDoc = new SolrInputDocument();
add.solrDoc.addField("id", Integer.toString(i));
for (int j = 0; j < fields.length; j += 2) {
String f = fields[j];
String val = fields[j + 1];
add.solrDoc.addField(f, val);
}
updateHandler.addDoc(add);
}
log.info("doc=" + Arrays.toString(fields));
double elapsed = timer.getTime();
log.info("iter=" + iter + " time=" + elapsed + " throughput=" + ((long) iter * 1000) / elapsed);
//discard all the changes
updateHandler.rollback(new RollbackUpdateCommand(req));
req.close();
}
use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class TestSearchPerf method doSetGen.
int doSetGen(int iter, Query q) throws Exception {
SolrQueryRequest req = lrf.makeRequest();
SolrIndexSearcher searcher = req.getSearcher();
final RTimer timer = new RTimer();
int ret = 0;
for (int i = 0; i < iter; i++) {
DocSet set = searcher.getDocSetNC(q, null);
ret += set.size();
}
double elapsed = timer.getTime();
System.out.println("ret=" + ret + " time=" + elapsed + " throughput=" + iter * 1000 / (elapsed + 1));
req.close();
// make sure we did some work
assertTrue(ret > 0);
return ret;
}
use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class TestSolrJ method main.
public static void main(String[] args) throws Exception {
// String addr = "http://odin.local:80/solr";
// String addr = "http://odin.local:8983/solr";
String addr = "http://127.0.0.1:8983/solr";
int i = 0;
final int nDocs = Integer.parseInt(args[i++]);
final int nProducers = Integer.parseInt(args[i++]);
final int nConnections = Integer.parseInt(args[i++]);
final int maxSleep = Integer.parseInt(args[i++]);
ConcurrentUpdateSolrClient concurrentClient = null;
// server = concurrentClient = new ConcurrentUpdateSolrServer(addr,32,8);
client = concurrentClient = getConcurrentUpdateSolrClient(addr, 64, nConnections);
client.deleteByQuery("*:*");
client.commit();
final RTimer timer = new RTimer();
final int docsPerThread = nDocs / nProducers;
Thread[] threads = new Thread[nProducers];
for (int threadNum = 0; threadNum < nProducers; threadNum++) {
final int base = threadNum * docsPerThread;
threads[threadNum] = new Thread("add-thread" + i) {
@Override
public void run() {
try {
indexDocs(base, docsPerThread, maxSleep);
} catch (Exception e) {
System.out.println("###############################CAUGHT EXCEPTION");
e.printStackTrace();
ex = e;
}
}
};
threads[threadNum].start();
}
for (int threadNum = 0; threadNum < nProducers; threadNum++) {
threads[threadNum].join();
}
if (concurrentClient != null) {
concurrentClient.blockUntilFinished();
}
double elapsed = timer.getTime();
System.out.println("time=" + elapsed + " throughput=" + (nDocs * 1000 / elapsed) + " Exception=" + ex);
// should server threads be marked as daemon?
// need a server.close()!!!
}
use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class AbstractCurrencyFieldTest method testPerformance.
@Ignore
public void testPerformance() throws Exception {
clearIndex();
Random r = random();
int initDocs = 200000;
for (int i = 1; i <= initDocs; i++) {
assertU(adoc("id", "" + i, field(), (r.nextInt(10) + 1.00) + ",USD"));
if (i % 1000 == 0)
System.out.println(i);
}
assertU(commit());
for (int i = 0; i < 1000; i++) {
double lower = r.nextInt(10) + 1.00;
assertQ(req("fl", "*,score", "q", field() + ":[" + lower + ",USD TO " + (lower + 10.00) + ",USD]"), "//*");
assertQ(req("fl", "*,score", "q", field() + ":[" + lower + ",EUR TO " + (lower + 10.00) + ",EUR]"), "//*");
}
for (int j = 0; j < 3; j++) {
final RTimer timer = new RTimer();
for (int i = 0; i < 1000; i++) {
double lower = r.nextInt(10) + 1.00;
assertQ(req("fl", "*,score", "q", field() + ":[" + lower + ",USD TO " + (lower + (9.99 - (j * 0.01))) + ",USD]"), "//*");
}
System.out.println(timer.getTime());
}
System.out.println("---");
for (int j = 0; j < 3; j++) {
final RTimer timer = new RTimer();
for (int i = 0; i < 1000; i++) {
double lower = r.nextInt(10) + 1.00;
assertQ(req("fl", "*,score", "q", field() + ":[" + lower + ",EUR TO " + (lower + (9.99 - (j * 0.01))) + ",EUR]"), "//*");
}
System.out.println(timer.getTime());
}
}
use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class TestFastLRUCache method cachePerfTest.
void cachePerfTest(final SolrCache sc, final int nThreads, final int numGets, int cacheSize, final int maxKey) {
Map l = new HashMap();
l.put("size", "" + cacheSize);
l.put("initialSize", "" + cacheSize);
Object o = sc.init(l, null, null);
sc.setState(SolrCache.State.LIVE);
fillCache(sc, cacheSize, maxKey);
final RTimer timer = new RTimer();
Thread[] threads = new Thread[nThreads];
final AtomicInteger puts = new AtomicInteger(0);
for (int i = 0; i < threads.length; i++) {
final int seed = random().nextInt();
threads[i] = new Thread() {
@Override
public void run() {
int ret = useCache(sc, numGets / nThreads, maxKey, seed);
puts.addAndGet(ret);
}
};
}
for (Thread thread : threads) {
try {
thread.start();
} catch (Exception e) {
e.printStackTrace();
}
}
for (Thread thread : threads) {
try {
thread.join();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("time=" + timer.getTime() + " impl=" + sc.getClass().getSimpleName() + " nThreads= " + nThreads + " size=" + cacheSize + " maxKey=" + maxKey + " gets=" + numGets + " hitRatio=" + (1 - (((double) puts.get()) / numGets)));
}
Aggregations