Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 64548 Details for
Bug 160389
[api] change how offline task data is cached to disk and refactor attribute factory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
naive performance test
PersistenceTest.java (text/plain), 5.36 KB, created by
Eugene Kuleshov
on 2007-04-22 15:08:51 EDT
(
hide
)
Description:
naive performance test
Filename:
MIME Type:
Creator:
Eugene Kuleshov
Created:
2007-04-22 15:08:51 EDT
Size:
5.36 KB
patch
obsolete
>package db4o; > >import java.io.File; >import java.io.IOException; >import java.io.Serializable; >import java.io.UnsupportedEncodingException; > >import org.apache.lucene.analysis.SimpleAnalyzer; >import org.apache.lucene.document.Document; >import org.apache.lucene.document.Field; >import org.apache.lucene.index.IndexReader; >import org.apache.lucene.index.IndexWriter; >import org.apache.lucene.index.Term; >import org.apache.lucene.search.Hits; >import org.apache.lucene.search.IndexSearcher; >import org.apache.lucene.search.PhraseQuery; > >import com.db4o.Db4o; >import com.db4o.ObjectContainer; >import com.db4o.ObjectSet; >import com.db4o.query.Predicate; > >import com.sleepycat.bind.EntryBinding; >import com.sleepycat.bind.serial.ClassCatalog; >import com.sleepycat.bind.serial.SerialBinding; >import com.sleepycat.bind.serial.StoredClassCatalog; >import com.sleepycat.je.Database; >import com.sleepycat.je.DatabaseConfig; >import com.sleepycat.je.DatabaseEntry; >import com.sleepycat.je.DatabaseException; >import com.sleepycat.je.Environment; >import com.sleepycat.je.EnvironmentConfig; >import com.sleepycat.je.LockMode; >import com.sleepycat.je.OperationStatus; > >public class PersistenceTest { > > public static void main(String[] args) throws Exception { > testbdb(); > testLucene(); > testdb4o(); > } > > > private static void testbdb() throws DatabaseException, UnsupportedEncodingException { > long l1 = System.currentTimeMillis(); > > EnvironmentConfig envConfig = new EnvironmentConfig(); > envConfig.setAllowCreate(true); > > Environment env = new Environment(new File("bdb.database"), envConfig); > > DatabaseConfig dbConfig = new DatabaseConfig(); > dbConfig.setAllowCreate(true); > > Database db = env.openDatabase(null, "bdb.database", dbConfig); > > ClassCatalog catalog = new StoredClassCatalog(db); > EntryBinding binding = new SerialBinding(catalog, Simple.class); > > for (int i = 0; i < 1000; i++) { > Simple simple = new Simple("group", "foo " + i, i); > > DatabaseEntry key = new DatabaseEntry(Integer.toString(i).getBytes("UTF-8")); > DatabaseEntry data = new DatabaseEntry(); > > binding.objectToEntry(simple, data); > > db.put(null, key, data); > } > > long l2 = System.currentTimeMillis(); > System.err.println("bdb: " + (l2-l1)/1000f); > > // need to use "secondary database" for retrieving by "group" field > for (int i = 0; i < 1000; i++) { > DatabaseEntry key = new DatabaseEntry(Integer.toString(i).getBytes("UTF-8")); > DatabaseEntry data = new DatabaseEntry(); > > if(db.get(null, key, data, LockMode.DEFAULT)!=OperationStatus.SUCCESS) { > System.err.println("Can't find " + i); > } > } > long l3 = System.currentTimeMillis(); > System.err.println("bdb: " + (l3-l2)/1000f); > > > db.close(); > } > > > > private static void testLucene() throws IOException { > IndexWriter w = new IndexWriter("lucene.database", new SimpleAnalyzer(), true); > > long l1 = System.currentTimeMillis(); > for (int i = 0; i < 1000; i++) { > Document doc = new Document(); > doc.add(new Field("group", "group", Field.Store.YES, Field.Index.UN_TOKENIZED)); > doc.add(new Field("foo", "foo " + i, Field.Store.YES, Field.Index.UN_TOKENIZED)); > doc.add(new Field("n", Integer.toString(i), Field.Store.YES, Field.Index.UN_TOKENIZED)); > > w.updateDocument(new Term("n", Integer.toString(i)), doc); > } > > w.optimize(); > w.close(); > > long l2 = System.currentTimeMillis(); > System.err.println("lucene: " + (l2-l1)/1000f); > > IndexReader r = IndexReader.open("lucene.database"); > IndexSearcher s = new IndexSearcher(r); > PhraseQuery q = new PhraseQuery(); > q.add(new Term("group", "group")); > Hits hits = s.search(q); > > if(hits.length()!=1000) { > System.err.println("lucene: Invalid search result"); > } > > long l3 = System.currentTimeMillis(); > System.err.println("lucene: " + (l3-l2)/1000f); > } > > > private static void testdb4o() { > ObjectContainer db = Db4o.openFile("db4o.database"); > > long l1 = System.currentTimeMillis(); > for (int i = 0; i < 1000; i++) { > final Simple s = new Simple("group", "foo " + i, i); > >// ObjectSet<Simple> set = db.query(new Predicate<Simple>() { >// public boolean match(Simple s1) { >// return s1.foo.equals(s.foo) && s1.n==s.n; >// }}); > > ObjectSet<Simple> set = db.get(s); > if(set.hasNext()) { > db.set(set.next()); > } else { > db.set(s); > } > } > > db.commit(); > > long l2 = System.currentTimeMillis(); > System.err.println("db4o: " + (l2-l1)/1000f); > > ObjectSet<Simple> set = db.query(new Predicate<Simple>() { > public boolean match(Simple s) { > return s.group.equals("group"); > } > }); > > if(set.size()!=1000) { > System.err.println("db4o: Invalid search result " + set.size()); > } > > long l3 = System.currentTimeMillis(); > System.err.println("db4o: " + (l3-l2)/1000f); > > db.close(); > } > > > private static final class Simple implements Serializable { > String group; > String foo; > int n; > > public Simple(String group, String foo, int n) { > this.group = group; > this.foo = foo; > this.n = n; > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 160389
: 64548 |
65355
|
71577
|
71578
|
71639
|
71646
|
71653
|
71660
|
71670
|
71673