Consider for example usage of the thread safe StringBuffer.
举例来说,考虑一下线程安全的StringBuffer的用法。
For comparison, Table 2 includes times for String and StringBuffer.
为了比较,表2还包含了String和StringBuffer的时间。
The first step here is to add a new member variable, a StringBuffer called elementContent.
这里的第一步是添加一个新的成员变量,即一个名为elementcontent的StringBuffer。
The familiar advice is; use StringBuffer instead of a String if you are going to be mutating it.
一个类似的建议是,如果你希望字符串是可变的,就应该使用StringBuffer。
Figure 4 shows a dramatic difference between Rope and StringBuffer that was not apparent in Figure 3.
图4显示了图3中不太明显的Rope和StringBuffer之间的巨大区别。
So far, I've relied on graphs to illustrate the performance differences among Rope, String, and StringBuffer.
迄今为止,已经用图表展示了Rope、String和StringBuffer之间的性能差异。
String is immutable and if we are doing work that requires mutations, StringBuffer is a less costly alternative.
String是不可变的,但如果我们的工作需要字符串有很多变化,StringBuffer将是一个开销较低的选择。
Based on the results, an accurate estimate for this particular StringBuffer implementation is somewhere around 1.5.
根据这些结果,可以准确地估算出这个StringBuffer实现大约在1.5左右。
If the binding corresponds to a variable, it creates a StringBuffer containing the variable's name, a colon, and its type.
如果该绑定和变量相对应,贡献器会创建一个包含该变量名、冒号和其类型的StringBuffer。
Figure 4 takes String out of the equation and rescales the chart to show more clearly how Rope and StringBuffer performance compare.
图4从比较中撤出 String的结果,调整了图表的比例,更清楚地显示了Rope和StringBuffer性能的对比。
However, there is a performance penalty here, since a StringBuffer must work to transparently increase its size and shift the data around.
不过此处有性能损失,因为StringBuffer必须透明地增加其大小和对数据移位。
To create the concatenated string "users.brian.accessRights", the compiler will create a temporary StringBuffer object, call StringBuffer.append
为创建串联的字符串 “users.brian.accessRights” ,编译器将创建一个临时的StringBuffer对象,调用 StringBuffer.append 三次,然后调用 StringBuffer.toString ,这意味着至少两个对象的创建和几个方法调用。
In part one of this article we used a single threaded benchmark to compare the performance of the synchronized StringBuffer to the unsynchronized StringBuilder.
在本文的第一部分中,我们通过一个单一线程的基准,比较了同步的StringBuffer和非同步的StringBuilder之间的性能。
If the IBinding is an IFunction, the contributor forms a StringBuffer containing the function's name and parameters — separated by commas and surrounded by parentheses.
如果IBinding是一个IFunction,贡献器会构造一个包含该函数名和参数(由逗号隔离并用圆括号括住)的StringBuffer。
You can sometimes further improve performance by setting the initial capacity of a StringBuffer; the class is designed to automatically grow when it can no longer hold all its data.
有时可以通过设置StringBuffer的初始容量进一步提高性能;该类的设计使其可以在不能保存全部数据时自动扩大容量。
Given the single threaded nature of this benchmark, I was fully expecting Escape Analysis to elide the lock thus rendering StringBuffer performance equivalent to that of StringBuilder.
明确了这个基准测试的单线程化的本质后,我期待着逸出分析会消除锁,从而将StringBuffer的性能提到了与StringBuilder相同的水平。
Given the single threaded nature of this benchmark, I was fully expecting Escape Analysis to elide the lock thus rendering StringBuffer performance equivalent to that of StringBuilder.
明确了这个基准测试的单线程化的本质后,我期待着逸出分析会消除锁,从而将StringBuffer的性能提到了与StringBuilder相同的水平。
应用推荐