Dictionary: hard-coded vs. external file
I have a java application which is started and stopped multiple times per second over hundreds of millions of items (called from an external script).
Input: String key Output: int value
The purpose of this application is to look for a certain key in a never ever ever changing Map (~30k keys) and to return the value. Very easy.
Question: what is more efficient when used multiple times per second:
- hard-coded dictionary in a Map
- Read an external file with a BufferedReader
- ...amaze me with your other ideas
I know hard-coding is evil but sometimes, you need to be evil to be efficient :-)
Read in the dictionary from file. Store it in a Map. Set up your Java application as a service that runs continuously (since you said it gets called many times per second). Then your Map will be cached in RAM.