Created
November 13, 2016 08:24
-
-
Save vladimirdolzhenko/4f50037e09aac8fa72e61021019e1eb5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | |
* @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