Package org.github.jamm.string
Class StringMeter
java.lang.Object
org.github.jamm.string.StringMeter
Utility to measure the value field of a
String
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
Enable or disable string optimization through theorg.github.jamm.string.Optimize
String system property.static final long
The String shallow size stored as a constant to have it compiled directly into the measure method. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
measureDeep
(MemoryMeterStrategy strategy, String s) Measure the deep size of the specified String.protected abstract long
measureStringValue
(MemoryMeterStrategy strategy, String s) Measure the size of the value of the specified String.static StringMeter
Creates a newStringMeter
instance.
-
Field Details
-
ENABLED
public static final boolean ENABLEDEnable or disable string optimization through theorg.github.jamm.string.Optimize
String system property.true
by default. -
STRING_SHALLOW_SIZE
public static final long STRING_SHALLOW_SIZEThe String shallow size stored as a constant to have it compiled directly into the measure method.
-
-
Constructor Details
-
StringMeter
public StringMeter()
-
-
Method Details
-
measureDeep
Measure the deep size of the specified String.- Parameters:
strategy
- the strategy to perform the measurements
- the string- Returns:
- the size of the deep string
-
measureStringValue
Measure the size of the value of the specified String.- Parameters:
strategy
- the strategy to perform the measurements
- the string- Returns:
- the size of the string value field
-
newInstance
Creates a newStringMeter
instance.- Returns:
- a new
StringMeter
instance.
-