Created
July 6, 2018 17:16
-
-
Save mbaumbach/e6e5114bb9220fdd37088608dab9e463 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
| import java.util.concurrent.TimeUnit; | |
| import liqp.Template; | |
| public class Playground { | |
| private static void parse(String template) { | |
| for (int i = 0; i < 10; i++) { | |
| long start = System.nanoTime(); | |
| Template.parse(template); | |
| System.out.println("Parse time (attempt: " + (i + 1) + "): " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start)); | |
| } | |
| } | |
| public static void main(String[] args) throws Exception { | |
| String small = "Hello {{ name }}, how are you doing today? Hope this performs well!"; | |
| String medium = ""; | |
| for (int i = 0; i < 100; i++) { | |
| medium += small + "\n"; | |
| } | |
| String large = ""; | |
| for (int i = 0; i < 500; i++) { | |
| large += small + "\n"; | |
| } | |
| System.out.println("Parsing small"); | |
| parse(small); | |
| System.out.println("Parsing medium"); | |
| parse(medium); | |
| System.out.println("Parsing large"); | |
| parse(large); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment