Friday, June 28, 2013

Benchmark: Fetching NoteIDs and documents from view

Update 28.06.13: I added a test - using the new NoteCollection.getNoteIds that was introduced in Domino 9.

In relation to an experiment I'm working on, I wrote a Java test agent to find the fastest way to get note id's from a view/fetching document values from documents in a view.

Here are the results from the benchmark:



All numbers are milliseconds. The code was run on a desktop computer (Core 2 Duo/Windows XP).

The benchmark code is written so that I think caching on the server is avoided between tests. What's interesting from the results is that it seems like it's marginally faster to fetch the note ids from the view/open the document by note id if you want to read values from the document.

If you want to run the benchmark in your application, here's the source code:
>> Download

The code is designed for running the test agent in a browser. Change the constants TEST_VIEW_NAME to the name of a view you want to test, and TEST_FIELD_NAME to a field name that the documents in the view have.

If you run the benchmark/get different results, let me know :)

8 comments:

Karsten Lehmann said...

There is a new method in NoteCollection in R9 to get all note ids as an int[] array which can speed up your test case no 2.

Tommy Valand said...

I saw that, but I didn't spend time figuring out how to convert it to a usable string. If you have a snippet, I'll update my results :P

Tommy Valand said...

Never mind. I found it.

Integer.toHexString( noteIdInteger ).

I'll update the result/code.

Karsten Lehmann said...

BTW I also found out that it's a lot faster to use DocumentCollection.merge(int) instead of .merge(String) and do the int-String conversion of the note id in Java. The C code in the C API to convert between int and String seems to be pretty bad.

Tommy Valand said...

Thanks for the information :)

Code/results updated.

the-ntf said...

Thanks Tommy!

https://github.com/OpenNTF/org.openntf.domino/commit/99cf1a43014e14407e0d0d63a3b27df08834fc56

Tommy Valand said...

No problem.. :)

One test, on one view/database, on one desktop is not necessarily proof. The code is written so that it should be simple to run the tests on different views/databases.

Create a java agent, paste the code, change the view name and field name constants. Run.

I forgot to mention that the server I ran the test on was 32 bit Domino 9.

I also tested NoteCollection.add( View ). The performance was more or less the same as with selection formula. Even though I specified that I only wanted the NoteCollection to contain documents, it seemed like the View also was added, as I got one more entry in the collection.

Karsten Lehmann said...

Another thing to try: use ViewEntry.getNoteIDAsInt() in the ViewNavigator case, also a new API in R9 and do the conversion to hex string in Java, if it's really necessary. You could also just work with int[], uses less memory anyway.

You might also try to read more docs, e.g. 40.000 fakenames entries. I'm sure then there will be a bigger difference between case 2 and 3.