Revision 3c01c7f7
Added by Andreas Kohlbecker over 12 years ago
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplBenchmark.java | ||
---|---|---|
74 | 74 |
|
75 | 75 |
private Taxon taxonAcherontia; |
76 | 76 |
|
77 |
private static final int BENCHMARK_ROUNDS = 10; |
|
78 |
|
|
77 |
private static final int BENCHMARK_ROUNDS = 20; |
|
79 | 78 |
|
80 | 79 |
@Before |
81 | 80 |
public void setUp() { |
... | ... | |
126 | 125 |
|
127 | 126 |
@Test |
128 | 127 |
@DataSet(value="TaxonDaoHibernateImplTest.xml") |
129 |
public void testCreateDelete() { |
|
130 |
Taxon parent = (Taxon)taxonDao.findByUuid(acherontiaLachesis); |
|
131 |
assert parent != null : "taxon cannot be null"; |
|
132 |
List<Taxon> newTaxa = new ArrayList<Taxon>(BENCHMARK_ROUNDS); |
|
133 |
|
|
134 |
for(int indx = 0; indx < BENCHMARK_ROUNDS; indx++){ |
|
135 |
Taxon child = Taxon.NewInstance(null, null); |
|
136 |
child.setTitleCache("Acherontia lachesis benchmark_" + indx + " Eitschberger, 2003", true); |
|
137 |
child.addTaxonRelation(parent, TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN(),null, null); |
|
138 |
newTaxa.add(child); |
|
139 |
logger.info("[" + indx + "] " + child.getTitleCache()); |
|
140 |
taxonDao.save(child); |
|
141 |
//commitAndStartNewTransaction(null); |
|
128 |
public void updateTaxon() { |
|
142 | 129 |
|
143 |
}
|
|
130 |
Taxon taxon = (Taxon) taxonDao.findByUuid(acherontiaLachesis);
|
|
144 | 131 |
|
145 |
for(Taxon child: newTaxa){ |
|
146 |
taxonDao.delete(child); |
|
132 |
long startMillis = System.currentTimeMillis(); |
|
133 |
for(int indx = 0; indx < BENCHMARK_ROUNDS; indx++){ |
|
134 |
taxon.setTitleCache("Acherontia lachesis benchmark_" + indx + " Eitschberger, 2003", true); |
|
135 |
taxonDao.saveOrUpdate(taxon); |
|
136 |
logger.debug("[" + indx + "]" + taxon.getTitleCache()); |
|
147 | 137 |
} |
148 |
|
|
149 |
// setComplete(); |
|
150 |
// endTransaction(); |
|
138 |
double duration = ((double)(System.currentTimeMillis() - startMillis) ) / BENCHMARK_ROUNDS ; |
|
139 |
logger.info("Benchmark result - [update one Taxon] : " + duration + "ms (" + BENCHMARK_ROUNDS +" benchmark rounds )"); |
|
151 | 140 |
} |
152 | 141 |
|
153 | 142 |
|
Also available in: Unified diff
add, remove, update Taxon benchmarks implemented