public class ContrivedFCTest extends TestCase {
public void testLoadTime() throws Exception {
Directory dir = FSDirectory.getDirectory(System.getProperty("java.io.tmpdir") + File.separator + "test");
IndexWriter writer = new IndexWriter (dir, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMergeFactor(37);
writer.setUseCompoundFile(false);
for(int i = 0; i < 5000000; i++) {
Document doc = new Document();
doc.add (new Field ("field", "String" + i, Field.Store.NO, Field.Index.NOT_ANALYZED));
writer.addDocument(doc);
}
writer.close();
IndexReader reader = IndexReader.open(dir);
long start = System.currentTimeMillis();
FieldCache.DEFAULT.getStrings(reader, "field");
long end = System.currentTimeMillis();
System.out.println("load time:" + (end - start)/1000.0f + "s");
}
}
Thursday 5 November 2009
Load Test: Lucene 2.4 VS Lucene 2.9
Posted by Prakash at 3:16 PM 0 comments
Tuesday 3 November 2009
List ports used by java process
Below is the command to list all the ports opened by a java process
sudo netstat -tulpn |grep java
Monday 26 October 2009
Python socket programming
I was in a situation to make the particular port listen,
Below code helped me in doing that simple.
import socket
#create an INET, STREAMing socket
serversocket = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
#bind the socket to a public host,
# and a well-known port
serversocket.bind((socket.gethostname(), 80))
#become a server socket
serversocket.listen(5)
Thursday 24 September 2009
To touch a folder contents recursive
Some times you may need to alter the access date of files and folder. You can do it by a recursive touch command.
find . | xargs touch
psql output to file
Below is the command to redirect psql output to a file.
psql> \o /tmp/file.txt
psql> select * from table
This should allow output to custom file.
Posted by Prakash at 6:46 PM 0 comments
