which is faster between Sqlite and dictionary?

For my game there are lots of information about monters, heros, items and so on.

And I will save them into containers as a database.

I want to know which is faster between Dictionary template or sqlite.

Option 1. Use Dictionary template.

Save data into Dictionary and find a item with key like

Value cItem = Dictionary[key];

Option 2. Use sqlite.

Create table for each group of information and query what I want to find.

Briefly, I want to pick faster one either dictionary or Sqlite as a database of all of the information about my game.

Any ideas?

Answers


If I were you I'd write an interface containing all methods required to store and retrieve this information, then create an implementation of that interface that is most straightforward to write.

Once you find that this part of your application is the bottleneck, replace the implementation of the interface with a faster one.

This way you won't waste time (human time) on finding the fastest solution for something that might not delay your application at all.

To answer your question though, SQLite goes through multiple layers (SQLite library, Native calls, query parsing) so even if you use an in-memory database it wouldn't perform as fast as a simple Dictionary lookup.

If you intend to store the data on disk, and/or run custom queries on the data, SQLite would be a very good option.


Need Your Help

How to fade in element after scrolled to

jquery scroll fadein sticky

I'm using a scroll to script which changes the display of the element from none to block when a certain point is reached on the page.