Search code examples
mongodbhibernatepersistencehibernate-ogmnosql

Measuring performance of MongoDB + Hibernate OGM in application


I have an application (MongoDB + Hibernate OGM) that contains some features. I would like to measure the performance of the persistence technology for certain operations (search, adding, deleting etc.) for those particular features.

Because I am measuring the performance of those features, I would think the best way would be to measure operations inside the application and not outside from it. I am not quite sure whether this approach is correct.

For instance, what I do now is:

long startTime = System.currentTimeMillis();
personDao.persist(persons.get(i));
long endTime = System.currentTimeMillis() - startTime;
System.out.println("End:" + endTime);

However, is it fair to measure it like this? Does someone have any tips to measure the performance of the persistence technology? Based on this, I would like to compare it with other persistence technology (such as MySQL + Hibernate ORM or another NoSQL technology like Cassandra).


Solution

  • Check out this answer to learn more about writing micro benchmarks in Java. Then I recommend to take a look at JMH for writing benchmarks.