Skip to content

Instantly share code, notes, and snippets.

@vladimirdolzhenko
Created November 13, 2016 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladimirdolzhenko/4f50037e09aac8fa72e61021019e1eb5 to your computer and use it in GitHub Desktop.
Save vladimirdolzhenko/4f50037e09aac8fa72e61021019e1eb5 to your computer and use it in GitHub Desktop.
package perf;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import org.junit.Test;
/**
* run with
* <code>-verbose:gc -XX:+PrintGCDetails -Xloggc:gc.log</code>
* get the total GC pause time
* <code>$ grep "GC" gc.log | grep "Times: " | awk '{S+=$8}END{print S}'</code>
*
* @author vladimir.dolzhenko@gmail.com
* @since 2016-11-12
*/
public class TestInternCache {
@Test
public void collectGCTimings() throws Exception {
StringBuilder builder = new StringBuilder("{");
for(int i = 0; i < 10000; i++){
if (i > 0) {
builder.append(", \n");
}
builder.append('"')
.append("someQName")
.append(i)
.append("\": ")
.append(i);
}
builder.append("}");
int c = 0;
for(int i = 0; i < 5000; i++) {
final JsonFactory factory = new JsonFactory();
JsonParser parser = factory.createParser(builder.toString());
while (parser.nextValue() != null) {
JsonToken x = parser.currentToken();
c += x.ordinal();
}
}
System.out.println(c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment