在内存和计算方面,哪一种是更有效的访问(关键,价值)对子的方法:读取属性文件,使用属性“getProperty”(“键”)读取,或者将整个属性文件装入程序开始时的哈什马普,然后在哈什马普查找密钥?
此外,如果从属性中得出的值中只有1个被反复使用,是否最好在成员变量中存储该值并访问该变量,或者每次使用属性时都查找该值。 getProperty (“密钥 ”)?
在内存和计算方面,哪一种是更有效的访问(关键,价值)对子的方法:读取属性文件,使用属性“getProperty”(“键”)读取,或者将整个属性文件装入程序开始时的哈什马普,然后在哈什马普查找密钥?
此外,如果从属性中得出的值中只有1个被反复使用,是否最好在成员变量中存储该值并访问该变量,或者每次使用属性时都查找该值。 getProperty (“密钥 ”)?
property.get Property (“键”)
是来自 Hashable 的查询, 即属性对象。 当您进行 property.load ()
时, 从文件装入条目, 并将其存储到扩展 Hashable 的属性对象中。 对属性的每一次访问都会在 Hashable 中查找。 没有 IO 文件了 。
当然,访问成员变量比从Hashmap 的钥匙中获取一个值要快一点,但我怀疑这是您在性能方面能取得任何显著成果的地方。一个Hashmap 的查看是 O(1), 速度非常快 。 您可能需要数百万次的查看才能发现差异。 做最容易读的东西 。
实际上, System.getProperty ()
使用一个 java. util. property
对象内部。 property
类扩展了 HashTable<Object,Object>
, 所以 so so so so so 将使用 HashMap
来明确表达, 不太可能获得很多的性能。
然而, 如果您经常使用少量属性, 如果将这些属性存储在变量中, 肯定会有帮助 。 Hashtable/ HashMap 查看和可变访问可能都是 O(1), 但是 Hashtable 查看肯定有一个更大的常数系数 。
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...