diff --git a/README.MD b/README.MD index 429a6c7..5149583 100644 --- a/README.MD +++ b/README.MD @@ -2,6 +2,9 @@ A [Mustache](https://mustache.github.io) implementation in pure Kotlin Multiplatform. +To see how it compares to [Mustache.java](https://github.com/spullara/mustache.java) +look [here](benchmark/README.MD) + # Import from maven ### Library @@ -185,7 +188,7 @@ With it, you can create template contexts anywhere in your code. Let's assume this document: -```mustache +```handlebars {{# greeting }} Hello {{ name }}, {{/ greeting }} diff --git a/benchmark/README.MD b/benchmark/README.MD new file mode 100644 index 0000000..29d3738 --- /dev/null +++ b/benchmark/README.MD @@ -0,0 +1,84 @@ +# Benchmark + +Benchmarks are run in the JVM and compare time execution of: + +- This lib `Ktm` +- [Mustache.java](https://github.com/spullara/mustache.java) + +The test is to parse and render the same document. + +1. Simple [[link](src/commonMain/kotlin/net/orandja/ktm/benchmark/Simple.kt)]: + +```handlebars +User: {{ firstName }} {{ lastName }} +``` + +2. Complex [[link](src/commonMain/kotlin/net/orandja/ktm/benchmark/Complex.kt)]: + +```handlebars +Hello {{user.firstName}} {{user.lastName}} +You have just won {{value}} dollars!
+{{#isTaxed}} + Today's win is taxed at {{ rate }}% +{{/isTaxed}} +``` + +3. Multiple (x1, x10, + x50) [[link](src/commonMain/kotlin/net/orandja/ktm/benchmark/Multiple.kt)]: + +```handlebars +

Last's winners

+Total number of winners : {{ winnersCount }} +{{#winners}} +
  • + {{user.firstName}} {{user.lastName}}
    + Amount : {{value}}{{#isTaxed}} at {{ rate }}%{{/isTaxed}} +
  • +{{/winners}} +``` + +### run + +- Smoke: `./gradlew :benchmark:jvmMainSmokeBenchmark` +- Full: `./gradlew :benchmark:jvmMainBenchmark` + +### Results + +Overall, performance is good: + +- Parsing documents in `Ktm` is faster than `Mustache.java`. +- Rendering documents in `Ktm` takes longer than `Mustache.java` for Multiple render + structures. + +
    +On my laptop: + +``` +OS: Kubuntu 23.10 x86_64 +Kernel: 6.5.0-15-generic +CPU: 13th Gen Intel i9-13900H (20) @ 5.200GHz +openjdk version "17.0.9" 2023-10-17 +``` + + +[View benchmark](https://jmh.morethan.io/?source=https://github.com/raw/L-Briand/KTM/master/benchmark/benchmark/Laptop.json) + +[raw json file](benchmark/Laptop.json) + +
    + +
    +On my mac mini: + +``` +Host: Mac mini 2023 +CPU: M2 +OS: macOS Sonoma Version 14.2.1 +java version "21.0.1" 2023-10-17-LTS +``` + +[View benchmark](https://jmh.morethan.io/?source=https://github.com/raw/L-Briand/KTM/master/benchmark/benchmark/MacMini.json) + +[raw json file](benchmark/MacMini.json) + +
    diff --git a/benchmark/benchmark/Laptop.json b/benchmark/benchmark/Laptop.json new file mode 100644 index 0000000..b54b279 --- /dev/null +++ b/benchmark/benchmark/Laptop.json @@ -0,0 +1,964 @@ +[ + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.ComplexBenchmark.LBriandKtmParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 2129.042480994081, + "scoreError" : 35.04283629313607, + "scoreConfidence" : [ + 2093.999644700945, + 2164.085317287217 + ], + "scorePercentiles" : { + "0.0" : 2094.406616728217, + "50.0" : 2128.5624667759575, + "90.0" : 2153.176486669559, + "95.0" : 2153.221966401524, + "99.0" : 2153.221966401524, + "99.9" : 2153.221966401524, + "99.99" : 2153.221966401524, + "99.999" : 2153.221966401524, + "99.9999" : 2153.221966401524, + "100.0" : 2153.221966401524 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 2123.348153825684, + 2152.767169081876, + 2151.918923106054, + 2151.41201636718, + 2118.7218643454976, + 2133.7767797262304, + 2153.221966401524, + 2115.108468365068, + 2095.7428519934783, + 2094.406616728217 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.ComplexBenchmark.LBriandKtmRender", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 641.5288077522367, + "scoreError" : 6.788094387071631, + "scoreConfidence" : [ + 634.7407133651651, + 648.3169021393084 + ], + "scorePercentiles" : { + "0.0" : 637.2082649971179, + "50.0" : 639.7137437902452, + "90.0" : 651.649760787619, + "95.0" : 652.3680482638911, + "99.0" : 652.3680482638911, + "99.9" : 652.3680482638911, + "99.99" : 652.3680482638911, + "99.999" : 652.3680482638911, + "99.9999" : 652.3680482638911, + "100.0" : 652.3680482638911 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 652.3680482638911, + 642.5578416911487, + 637.2082649971179, + 645.1851735011703, + 637.6181993144909, + 639.3205250674467, + 639.5703843339157, + 639.6825707199797, + 642.0321527726954, + 639.7449168605106 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.ComplexBenchmark.SpullaraMustacheParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 3832.493586021901, + "scoreError" : 44.22107764129931, + "scoreConfidence" : [ + 3788.2725083806017, + 3876.7146636632006 + ], + "scorePercentiles" : { + "0.0" : 3807.2205602993745, + "50.0" : 3815.8727983125855, + "90.0" : 3883.776099015168, + "95.0" : 3884.5608907878554, + "99.0" : 3884.5608907878554, + "99.9" : 3884.5608907878554, + "99.99" : 3884.5608907878554, + "99.999" : 3884.5608907878554, + "99.9999" : 3884.5608907878554, + "100.0" : 3884.5608907878554 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 3847.982118648959, + 3818.468724505575, + 3884.5608907878554, + 3876.71297306098, + 3808.4517582332487, + 3844.738734340079, + 3812.55585333496, + 3807.2205602993745, + 3813.276872119596, + 3810.967374888381 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.ComplexBenchmark.SpullaraMustacheRender", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 438.53050365574666, + "scoreError" : 5.923620910187619, + "scoreConfidence" : [ + 432.60688274555906, + 444.45412456593425 + ], + "scorePercentiles" : { + "0.0" : 433.82649906085027, + "50.0" : 437.2372594500613, + "90.0" : 444.92001217037046, + "95.0" : 444.9936871263773, + "99.0" : 444.9936871263773, + "99.9" : 444.9936871263773, + "99.99" : 444.9936871263773, + "99.999" : 444.9936871263773, + "99.9999" : 444.9936871263773, + "100.0" : 444.9936871263773 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 433.82649906085027, + 435.7057033921246, + 444.9936871263773, + 436.3640202332935, + 437.19584614575274, + 444.25693756630835, + 441.96686941867284, + 437.2786727543699, + 438.8646050621372, + 434.85219579757927 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.LBriandKtmParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 3094.7217727107873, + "scoreError" : 40.74015728164834, + "scoreConfidence" : [ + 3053.981615429139, + 3135.4619299924357 + ], + "scorePercentiles" : { + "0.0" : 3049.55405044159, + "50.0" : 3090.151565010743, + "90.0" : 3129.7773192187888, + "95.0" : 3129.922403405896, + "99.0" : 3129.922403405896, + "99.9" : 3129.922403405896, + "99.99" : 3129.922403405896, + "99.999" : 3129.922403405896, + "99.9999" : 3129.922403405896, + "100.0" : 3129.922403405896 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 3069.275371525785, + 3049.55405044159, + 3080.5493664335563, + 3086.0962918998653, + 3094.2068381216204, + 3129.922403405896, + 3127.6603149087528, + 3096.9605308521423, + 3128.47156153482, + 3084.52099798384 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.LBriandKtmRenderX01", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 1122.5257242606863, + "scoreError" : 9.810818956819107, + "scoreConfidence" : [ + 1112.7149053038672, + 1132.3365432175053 + ], + "scorePercentiles" : { + "0.0" : 1110.1157170693657, + "50.0" : 1122.310737550879, + "90.0" : 1133.0134569179802, + "95.0" : 1133.55996063126, + "99.0" : 1133.55996063126, + "99.9" : 1133.55996063126, + "99.99" : 1133.55996063126, + "99.999" : 1133.55996063126, + "99.9999" : 1133.55996063126, + "100.0" : 1133.55996063126 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 1128.0949234984616, + 1124.7564192298537, + 1118.0217728321265, + 1110.1157170693657, + 1119.7758936839084, + 1123.2879928985026, + 1133.55996063126, + 1118.8779475731747, + 1121.333482203255, + 1127.433132986955 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.LBriandKtmRenderX10", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 6048.947199486755, + "scoreError" : 77.28052420129083, + "scoreConfidence" : [ + 5971.666675285464, + 6126.227723688046 + ], + "scorePercentiles" : { + "0.0" : 6008.041212422201, + "50.0" : 6027.04879707865, + "90.0" : 6145.665035078272, + "95.0" : 6146.632657325895, + "99.0" : 6146.632657325895, + "99.9" : 6146.632657325895, + "99.99" : 6146.632657325895, + "99.999" : 6146.632657325895, + "99.9999" : 6146.632657325895, + "100.0" : 6146.632657325895 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 6146.632657325895, + 6136.956434849666, + 6051.929854359139, + 6046.4311280941265, + 6024.8764301048495, + 6008.546571660879, + 6008.041212422201, + 6011.9601118934925, + 6026.533891751283, + 6027.563702406017 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.LBriandKtmRenderX50", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 29185.535899487684, + "scoreError" : 280.8307771110224, + "scoreConfidence" : [ + 28904.70512237666, + 29466.366676598707 + ], + "scorePercentiles" : { + "0.0" : 28824.279638382908, + "50.0" : 29252.738555509764, + "90.0" : 29332.02658669216, + "95.0" : 29333.91691191568, + "99.0" : 29333.91691191568, + "99.9" : 29333.91691191568, + "99.99" : 29333.91691191568, + "99.999" : 29333.91691191568, + "99.9999" : 29333.91691191568, + "100.0" : 29333.91691191568 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 29315.01365968049, + 29244.045284857937, + 29289.34238297457, + 29229.675470558435, + 29200.034463964184, + 29333.91691191568, + 29298.29602359283, + 28859.323332788255, + 29261.431826161588, + 28824.279638382908 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.SpullaraMustacheParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 5942.01658378111, + "scoreError" : 12.853482938239235, + "scoreConfidence" : [ + 5929.163100842871, + 5954.870066719349 + ], + "scorePercentiles" : { + "0.0" : 5919.477876822059, + "50.0" : 5943.942188616014, + "90.0" : 5949.264965581372, + "95.0" : 5949.302002363654, + "99.0" : 5949.302002363654, + "99.9" : 5949.302002363654, + "99.99" : 5949.302002363654, + "99.999" : 5949.302002363654, + "99.9999" : 5949.302002363654, + "100.0" : 5949.302002363654 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 5945.2397656994635, + 5945.208103711014, + 5944.27338685391, + 5943.61099037812, + 5948.931634540836, + 5942.756966769071, + 5919.477876822059, + 5942.840895000287, + 5938.524215672691, + 5949.302002363654 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.SpullaraMustacheRenderX01", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 624.0634682616471, + "scoreError" : 5.706649614995992, + "scoreConfidence" : [ + 618.3568186466512, + 629.7701178766431 + ], + "scorePercentiles" : { + "0.0" : 619.8195795151812, + "50.0" : 623.4434328879299, + "90.0" : 629.6317136933733, + "95.0" : 629.8250197015607, + "99.0" : 629.8250197015607, + "99.9" : 629.8250197015607, + "99.99" : 629.8250197015607, + "99.999" : 629.8250197015607, + "99.9999" : 629.8250197015607, + "100.0" : 629.8250197015607 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 627.6780413704457, + 620.3479099799458, + 619.8195795151812, + 620.4797996018923, + 625.017243132121, + 620.9510229577428, + 629.8250197015607, + 626.7544840941566, + 627.8919596196865, + 621.8696226437387 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.SpullaraMustacheRenderX10", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 3978.822873268874, + "scoreError" : 55.95320735018865, + "scoreConfidence" : [ + 3922.8696659186853, + 4034.7760806190627 + ], + "scorePercentiles" : { + "0.0" : 3925.9826327959076, + "50.0" : 3983.5763261699967, + "90.0" : 4021.224294898833, + "95.0" : 4022.1506249170507, + "99.0" : 4022.1506249170507, + "99.9" : 4022.1506249170507, + "99.99" : 4022.1506249170507, + "99.999" : 4022.1506249170507, + "99.9999" : 4022.1506249170507, + "100.0" : 4022.1506249170507 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 3928.568393113418, + 3932.030038373629, + 3925.9826327959076, + 3983.5678229626956, + 3983.584829377298, + 4022.1506249170507, + 4008.6552805944184, + 3983.200406516478, + 4007.601379302975, + 4012.88732473487 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.SpullaraMustacheRenderX50", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 20200.735538280795, + "scoreError" : 261.6898958702959, + "scoreConfidence" : [ + 19939.0456424105, + 20462.42543415109 + ], + "scorePercentiles" : { + "0.0" : 20066.103621017148, + "50.0" : 20126.752562296006, + "90.0" : 20523.848124349694, + "95.0" : 20524.42992981352, + "99.0" : 20524.42992981352, + "99.9" : 20524.42992981352, + "99.99" : 20524.42992981352, + "99.999" : 20524.42992981352, + "99.9999" : 20524.42992981352, + "100.0" : 20524.42992981352 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 20524.42992981352, + 20518.611875175247, + 20193.748085077743, + 20066.103621017148, + 20096.339649940717, + 20136.650551707473, + 20161.599341442106, + 20083.29763108044, + 20109.720124669057, + 20116.85457288454 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.SimpleBenchmark.LBriandKtmParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 503.09902381563336, + "scoreError" : 8.937926959012264, + "scoreConfidence" : [ + 494.1610968566211, + 512.0369507746457 + ], + "scorePercentiles" : { + "0.0" : 497.4669913811114, + "50.0" : 500.4990721022441, + "90.0" : 513.4419483156502, + "95.0" : 513.6758517638829, + "99.0" : 513.6758517638829, + "99.9" : 513.6758517638829, + "99.99" : 513.6758517638829, + "99.999" : 513.6758517638829, + "99.9999" : 513.6758517638829, + "100.0" : 513.6758517638829 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 499.3596340026718, + 498.0513733633628, + 501.63851020181636, + 506.2365332169316, + 511.33681728155574, + 513.6758517638829, + 498.77106673485144, + 497.4669913811114, + 498.2636954945813, + 506.18976471556863 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.SimpleBenchmark.LBriandKtmRender", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 161.2993082875965, + "scoreError" : 2.0600929589589856, + "scoreConfidence" : [ + 159.2392153286375, + 163.35940124655548 + ], + "scorePercentiles" : { + "0.0" : 159.14346069515062, + "50.0" : 161.55998877611978, + "90.0" : 162.751102009967, + "95.0" : 162.76018365086523, + "99.0" : 162.76018365086523, + "99.9" : 162.76018365086523, + "99.99" : 162.76018365086523, + "99.999" : 162.76018365086523, + "99.9999" : 162.76018365086523, + "100.0" : 162.76018365086523 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 160.38610478219871, + 159.14346069515062, + 160.4277780439487, + 161.238886535212, + 161.88109101702753, + 162.76018365086523, + 162.66936724188292, + 162.66553333712514, + 162.3151529775327, + 159.5055245950212 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.SimpleBenchmark.SpullaraMustacheParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 1298.9535075216324, + "scoreError" : 14.377308032325185, + "scoreConfidence" : [ + 1284.5761994893073, + 1313.3308155539576 + ], + "scorePercentiles" : { + "0.0" : 1286.9784683925698, + "50.0" : 1296.8945182777757, + "90.0" : 1312.5591662844272, + "95.0" : 1312.6939180092677, + "99.0" : 1312.6939180092677, + "99.9" : 1312.6939180092677, + "99.99" : 1312.6939180092677, + "99.999" : 1312.6939180092677, + "99.9999" : 1312.6939180092677, + "100.0" : 1312.6939180092677 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 1286.9784683925698, + 1302.9933381078558, + 1312.6939180092677, + 1308.6561557965942, + 1297.1193288820407, + 1311.3464007608632, + 1291.299611352133, + 1287.6928843998787, + 1296.6697076735109, + 1294.0852618416109 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.SimpleBenchmark.SpullaraMustacheRender", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/usr/lib/jvm/java-17-openjdk-amd64/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=US", + "-Duser.language=en", + "-Duser.variant" + ], + "jdkVersion" : "17.0.9", + "vmName" : "OpenJDK 64-Bit Server VM", + "vmVersion" : "17.0.9+9-Ubuntu-123.10", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 162.20863420769263, + "scoreError" : 1.8708989651121282, + "scoreConfidence" : [ + 160.3377352425805, + 164.07953317280476 + ], + "scorePercentiles" : { + "0.0" : 160.8900048558775, + "50.0" : 161.90135463495454, + "90.0" : 164.0600071650631, + "95.0" : 164.1170249223561, + "99.0" : 164.1170249223561, + "99.9" : 164.1170249223561, + "99.99" : 164.1170249223561, + "99.999" : 164.1170249223561, + "99.9999" : 164.1170249223561, + "100.0" : 164.1170249223561 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 161.61751377570957, + 161.07541037116812, + 160.8900048558775, + 160.97374364371814, + 163.54684734942606, + 163.08276345326368, + 164.1170249223561, + 161.14323430411082, + 162.18519549419952, + 163.45460390709692 + ] + ] + }, + "secondaryMetrics" : { + } + } +] + + diff --git a/benchmark/benchmark/MacMini.json b/benchmark/benchmark/MacMini.json new file mode 100644 index 0000000..05f2cb4 --- /dev/null +++ b/benchmark/benchmark/MacMini.json @@ -0,0 +1,964 @@ +[ + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.ComplexBenchmark.LBriandKtmParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 2246.731910953798, + "scoreError" : 2.130513213416243, + "scoreConfidence" : [ + 2244.601397740382, + 2248.862424167214 + ], + "scorePercentiles" : { + "0.0" : 2244.1195533406776, + "50.0" : 2246.9970165172635, + "90.0" : 2248.6979749037814, + "95.0" : 2248.737393847062, + "99.0" : 2248.737393847062, + "99.9" : 2248.737393847062, + "99.99" : 2248.737393847062, + "99.999" : 2248.737393847062, + "99.9999" : 2248.737393847062, + "100.0" : 2248.737393847062 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 2244.1195533406776, + 2248.737393847062, + 2246.885252581744, + 2245.945092393183, + 2247.483219592599, + 2248.3432044142587, + 2247.1087804527833, + 2246.299440588961, + 2245.1203855975027, + 2247.2767867292055 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.ComplexBenchmark.LBriandKtmRender", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 610.0530009392105, + "scoreError" : 0.5379927680872291, + "scoreConfidence" : [ + 609.5150081711233, + 610.5909937072977 + ], + "scorePercentiles" : { + "0.0" : 609.5669527406857, + "50.0" : 610.0580985057436, + "90.0" : 610.6354596526071, + "95.0" : 610.6671790236551, + "99.0" : 610.6671790236551, + "99.9" : 610.6671790236551, + "99.99" : 610.6671790236551, + "99.999" : 610.6671790236551, + "99.9999" : 610.6671790236551, + "100.0" : 610.6671790236551 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 609.7774678924703, + 610.0001605238849, + 610.6671790236551, + 609.7069532040168, + 610.1160364876023, + 610.2892415217613, + 609.7292626426565, + 609.5669527406857, + 610.3267700421975, + 610.3499853131749 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.ComplexBenchmark.SpullaraMustacheParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 2815.419181636086, + "scoreError" : 15.388269009602507, + "scoreConfidence" : [ + 2800.0309126264833, + 2830.8074506456883 + ], + "scorePercentiles" : { + "0.0" : 2805.1355924292284, + "50.0" : 2812.227766924466, + "90.0" : 2839.8962977054043, + "95.0" : 2842.187655526015, + "99.0" : 2842.187655526015, + "99.9" : 2842.187655526015, + "99.99" : 2842.187655526015, + "99.999" : 2842.187655526015, + "99.9999" : 2842.187655526015, + "100.0" : 2842.187655526015 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 2809.4246336331166, + 2805.1355924292284, + 2810.9193635892534, + 2811.6766204727596, + 2814.581734241809, + 2812.7789133761717, + 2811.4679839152027, + 2842.187655526015, + 2819.274077319907, + 2816.7452418573926 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.ComplexBenchmark.SpullaraMustacheRender", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 458.37982804124783, + "scoreError" : 0.21186719319778147, + "scoreConfidence" : [ + 458.16796084805003, + 458.59169523444564 + ], + "scorePercentiles" : { + "0.0" : 458.14454122221116, + "50.0" : 458.3646531178346, + "90.0" : 458.6017194664906, + "95.0" : 458.6056160294739, + "99.0" : 458.6056160294739, + "99.9" : 458.6056160294739, + "99.99" : 458.6056160294739, + "99.999" : 458.6056160294739, + "99.9999" : 458.6056160294739, + "100.0" : 458.6056160294739 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 458.35392436423905, + 458.3663943967523, + 458.4237273750303, + 458.14454122221116, + 458.6056160294739, + 458.5666503996408, + 458.44942515408553, + 458.2690081092225, + 458.2560815229061, + 458.36291183891694 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.LBriandKtmParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 3427.995022864682, + "scoreError" : 15.844310286690337, + "scoreConfidence" : [ + 3412.1507125779917, + 3443.8393331513726 + ], + "scorePercentiles" : { + "0.0" : 3421.679356353459, + "50.0" : 3424.7039749121036, + "90.0" : 3454.4520431485375, + "95.0" : 3457.265012960208, + "99.0" : 3457.265012960208, + "99.9" : 3457.265012960208, + "99.99" : 3457.265012960208, + "99.999" : 3457.265012960208, + "99.9999" : 3457.265012960208, + "100.0" : 3457.265012960208 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 3422.940052282966, + 3424.431969194888, + 3426.1957084150717, + 3424.975980629319, + 3429.1353148435037, + 3457.265012960208, + 3421.679356353459, + 3423.634621790075, + 3424.09964925088, + 3425.5925629264507 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.LBriandKtmRenderX01", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 1267.982417466704, + "scoreError" : 2.0123841475224546, + "scoreConfidence" : [ + 1265.9700333191815, + 1269.9948016142264 + ], + "scorePercentiles" : { + "0.0" : 1264.99398431467, + "50.0" : 1268.300750012305, + "90.0" : 1269.5821247970766, + "95.0" : 1269.6145141453494, + "99.0" : 1269.6145141453494, + "99.9" : 1269.6145141453494, + "99.99" : 1269.6145141453494, + "99.999" : 1269.6145141453494, + "99.9999" : 1269.6145141453494, + "100.0" : 1269.6145141453494 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 1267.5164393112736, + 1268.7824697491137, + 1268.1445314379127, + 1267.1065912138265, + 1268.5766577248864, + 1268.4569685866968, + 1267.3413975206884, + 1264.99398431467, + 1269.2906206626224, + 1269.6145141453494 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.LBriandKtmRenderX10", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 5445.2089800514295, + "scoreError" : 10.172904897281725, + "scoreConfidence" : [ + 5435.0360751541475, + 5455.381884948712 + ], + "scorePercentiles" : { + "0.0" : 5428.302130675142, + "50.0" : 5447.208053669877, + "90.0" : 5453.1618151996745, + "95.0" : 5453.677760861163, + "99.0" : 5453.677760861163, + "99.9" : 5453.677760861163, + "99.99" : 5453.677760861163, + "99.999" : 5453.677760861163, + "99.9999" : 5453.677760861163, + "100.0" : 5453.677760861163 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 5442.12249054197, + 5428.302130675142, + 5453.677760861163, + 5444.684841596973, + 5448.424706652238, + 5448.51830424628, + 5443.773695637608, + 5447.137492857337, + 5448.169762963177, + 5447.278614482417 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.LBriandKtmRenderX50", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 29205.368432331423, + "scoreError" : 165.72937551911437, + "scoreConfidence" : [ + 29039.63905681231, + 29371.097807850536 + ], + "scorePercentiles" : { + "0.0" : 28991.233924783028, + "50.0" : 29249.8813743287, + "90.0" : 29290.013575654022, + "95.0" : 29291.530719183418, + "99.0" : 29291.530719183418, + "99.9" : 29291.530719183418, + "99.99" : 29291.530719183418, + "99.999" : 29291.530719183418, + "99.9999" : 29291.530719183418, + "100.0" : 29291.530719183418 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 29260.770922532258, + 29248.87369096584, + 28991.233924783028, + 29243.108944764645, + 29253.12193273146, + 29250.88905769156, + 29228.75648832685, + 29009.039358445745, + 29291.530719183418, + 29276.359283889462 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.SpullaraMustacheParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 4432.540788751377, + "scoreError" : 2.5648416471683895, + "scoreConfidence" : [ + 4429.975947104208, + 4435.105630398545 + ], + "scorePercentiles" : { + "0.0" : 4430.255765854349, + "50.0" : 4432.560226066062, + "90.0" : 4435.794858792321, + "95.0" : 4436.049823382034, + "99.0" : 4436.049823382034, + "99.9" : 4436.049823382034, + "99.99" : 4436.049823382034, + "99.999" : 4436.049823382034, + "99.9999" : 4436.049823382034, + "100.0" : 4436.049823382034 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 4430.524584783134, + 4433.476724224387, + 4436.049823382034, + 4431.978019437831, + 4433.223359685718, + 4433.500177484899, + 4430.255765854349, + 4432.816016907129, + 4431.278980529282, + 4432.3044352249935 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.SpullaraMustacheRenderX01", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 518.4558400334719, + "scoreError" : 0.5781734395321906, + "scoreConfidence" : [ + 517.8776665939397, + 519.034013473004 + ], + "scorePercentiles" : { + "0.0" : 517.8610250369334, + "50.0" : 518.5544415072097, + "90.0" : 518.965315746943, + "95.0" : 518.9856777888936, + "99.0" : 518.9856777888936, + "99.9" : 518.9856777888936, + "99.99" : 518.9856777888936, + "99.999" : 518.9856777888936, + "99.9999" : 518.9856777888936, + "100.0" : 518.9856777888936 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 517.9864826099399, + 518.3252135585454, + 518.7820573693883, + 518.0640322013843, + 518.7793906777914, + 518.6656380774226, + 517.8610250369334, + 518.9856777888936, + 518.4642254342409, + 518.6446575801784 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.SpullaraMustacheRenderX10", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 3338.4589267823712, + "scoreError" : 5.777580550661518, + "scoreConfidence" : [ + 3332.6813462317095, + 3344.236507333033 + ], + "scorePercentiles" : { + "0.0" : 3328.7149853215465, + "50.0" : 3339.6021191795326, + "90.0" : 3342.2999650633396, + "95.0" : 3342.4758755931025, + "99.0" : 3342.4758755931025, + "99.9" : 3342.4758755931025, + "99.99" : 3342.4758755931025, + "99.999" : 3342.4758755931025, + "99.9999" : 3342.4758755931025, + "100.0" : 3342.4758755931025 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 3328.7149853215465, + 3340.7167702954725, + 3339.389160446602, + 3339.1685745378786, + 3339.9297688290994, + 3342.4758755931025, + 3335.672633890935, + 3339.815077912463, + 3338.8418052462043, + 3339.864615750406 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.MultiComplexBenchmark.SpullaraMustacheRenderX50", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 17665.71983340181, + "scoreError" : 106.67172808023462, + "scoreConfidence" : [ + 17559.048105321577, + 17772.391561482043 + ], + "scorePercentiles" : { + "0.0" : 17616.542541979907, + "50.0" : 17643.509364432037, + "90.0" : 17840.352792412723, + "95.0" : 17858.35705414287, + "99.0" : 17858.35705414287, + "99.9" : 17858.35705414287, + "99.99" : 17858.35705414287, + "99.999" : 17858.35705414287, + "99.9999" : 17858.35705414287, + "100.0" : 17858.35705414287 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 17641.997106416948, + 17623.450188030576, + 17645.00637384199, + 17616.542541979907, + 17642.01235502209, + 17647.75907881005, + 17628.729199284604, + 17678.314436841392, + 17675.029999647686, + 17858.35705414287 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.SimpleBenchmark.LBriandKtmParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 669.9080770230183, + "scoreError" : 0.5913491665004634, + "scoreConfidence" : [ + 669.3167278565179, + 670.4994261895188 + ], + "scorePercentiles" : { + "0.0" : 669.2383228106187, + "50.0" : 669.9244946111269, + "90.0" : 670.416963199955, + "95.0" : 670.42476247293, + "99.0" : 670.42476247293, + "99.9" : 670.42476247293, + "99.99" : 670.42476247293, + "99.999" : 670.42476247293, + "99.9999" : 670.42476247293, + "100.0" : 670.42476247293 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 669.3806119186858, + 670.3467697431802, + 669.8897979085559, + 669.8433901715075, + 670.42476247293, + 670.2206641279221, + 669.2383228106187, + 670.0949269780455, + 669.6823327850389, + 669.9591913136979 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.SimpleBenchmark.LBriandKtmRender", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 102.150109806134, + "scoreError" : 0.10741530568309036, + "scoreConfidence" : [ + 102.0426945004509, + 102.25752511181709 + ], + "scorePercentiles" : { + "0.0" : 102.01571909884542, + "50.0" : 102.14574697968469, + "90.0" : 102.27683936316868, + "95.0" : 102.28395379468826, + "99.0" : 102.28395379468826, + "99.9" : 102.28395379468826, + "99.99" : 102.28395379468826, + "99.999" : 102.28395379468826, + "99.9999" : 102.28395379468826, + "100.0" : 102.28395379468826 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 102.21280947949239, + 102.18385286849816, + 102.13735845030529, + 102.1428068484253, + 102.28395379468826, + 102.14868711094408, + 102.01571909884542, + 102.13711044948107, + 102.08689570680576, + 102.15190425385408 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.SimpleBenchmark.SpullaraMustacheParse", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 1178.1512732722256, + "scoreError" : 3.993502874091236, + "scoreConfidence" : [ + 1174.1577703981343, + 1182.1447761463169 + ], + "scorePercentiles" : { + "0.0" : 1172.8217967335377, + "50.0" : 1178.7615843300978, + "90.0" : 1181.7786051108394, + "95.0" : 1181.880665014504, + "99.0" : 1181.880665014504, + "99.9" : 1181.880665014504, + "99.99" : 1181.880665014504, + "99.999" : 1181.880665014504, + "99.9999" : 1181.880665014504, + "100.0" : 1181.880665014504 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 1172.8217967335377, + 1175.679546784691, + 1179.5855641079374, + 1179.2278007479474, + 1177.1822083947418, + 1176.7519163008426, + 1178.462807461908, + 1179.0603611982874, + 1180.8600659778576, + 1181.880665014504 + ] + ] + }, + "secondaryMetrics" : { + } + }, + { + "jmhVersion" : "1.21", + "benchmark" : "net.orandja.ktm.benchmark.SimpleBenchmark.SpullaraMustacheRender", + "mode" : "avgt", + "threads" : 1, + "forks" : 1, + "jvm" : "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java", + "jvmArgs" : [ + "-Dfile.encoding=UTF-8", + "-Duser.country=FR", + "-Duser.language=fr", + "-Duser.variant" + ], + "jdkVersion" : "21.0.1", + "vmName" : "Java HotSpot(TM) 64-Bit Server VM", + "vmVersion" : "21.0.1+12-LTS-29", + "warmupIterations" : 20, + "warmupTime" : "3 s", + "warmupBatchSize" : 1, + "measurementIterations" : 10, + "measurementTime" : "3 s", + "measurementBatchSize" : 1, + "primaryMetric" : { + "score" : 175.497963236256, + "scoreError" : 0.10534470925523501, + "scoreConfidence" : [ + 175.39261852700076, + 175.60330794551123 + ], + "scorePercentiles" : { + "0.0" : 175.4196130225256, + "50.0" : 175.49449799052883, + "90.0" : 175.65334285167725, + "95.0" : 175.6686843567188, + "99.0" : 175.6686843567188, + "99.9" : 175.6686843567188, + "99.99" : 175.6686843567188, + "99.999" : 175.6686843567188, + "99.9999" : 175.6686843567188, + "100.0" : 175.6686843567188 + }, + "scoreUnit" : "ns/op", + "rawData" : [ + [ + 175.4372692807519, + 175.6686843567188, + 175.4196130225256, + 175.48283265878695, + 175.4386935214092, + 175.51526930630328, + 175.51369833319905, + 175.51457590180775, + 175.4861513097594, + 175.50284467129822 + ] + ] + }, + "secondaryMetrics" : { + } + } +] + + diff --git a/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Winner.kt b/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Complex.kt similarity index 82% rename from benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Winner.kt rename to benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Complex.kt index 2640742..3b6355d 100644 --- a/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Winner.kt +++ b/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Complex.kt @@ -4,8 +4,8 @@ import net.orandja.ktm.ksp.KtmContext @KtmContext -data class Winner( - val user: User, +data class Complex( + val user: Simple, val amount: Int, val isTaxed: Boolean, val rate: Int, @@ -19,8 +19,8 @@ data class Winner( {{/isTaxed}} """.trimIndent() - val CONTEXT = Winner( - user = User("John", "doe"), + val CONTEXT = Complex( + user = Simple("John", "doe"), amount = 125_000, isTaxed = true, rate = 20, diff --git a/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Winners.kt b/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Multiple.kt similarity index 64% rename from benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Winners.kt rename to benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Multiple.kt index cb5d8ab..fb4c5eb 100644 --- a/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Winners.kt +++ b/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Multiple.kt @@ -4,8 +4,8 @@ import net.orandja.ktm.ksp.KtmContext import kotlin.random.Random @KtmContext -data class Winners( - val winners: List, +data class Multiple( + val winners: List, val winnersCount: Int = winners.size ) { companion object { @@ -23,13 +23,13 @@ data class Winners( @OptIn(ExperimentalStdlibApi::class) private fun Random.nextString(length: Int) = nextBytes(length).toHexString() private fun makeWinner(seed: Int) = with(Random(seed)) { - val user = User(nextString(nextInt(4, 12)), nextString(nextInt(4, 12))) - Winner(user, nextInt(5000, 100000), nextBoolean(), nextInt(10, 20)) + val user = Simple(nextString(nextInt(4, 12)), nextString(nextInt(4, 12))) + Complex(user, nextInt(5000, 100000), nextBoolean(), nextInt(10, 20)) } - val CONTEXT_X01 = Winners(listOf(makeWinner(-1))) - val CONTEXT_X10 = Winners((0..<10).map { makeWinner(it) }) - val CONTEXT_X50 = Winners((0..<50).map { makeWinner(it + 10) }) + val CONTEXT_X01 = Multiple(listOf(makeWinner(-1))) + val CONTEXT_X10 = Multiple((0..<10).map { makeWinner(it) }) + val CONTEXT_X50 = Multiple((0..<50).map { makeWinner(it + 10) }) } } diff --git a/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Partial.kt b/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Partial.kt deleted file mode 100644 index 668c61e..0000000 --- a/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Partial.kt +++ /dev/null @@ -1,29 +0,0 @@ -package net.orandja.ktm.benchmark - -import net.orandja.ktm.ksp.KtmContext - -@KtmContext -data class Partial( - val title: String, - val content: T, -) { - companion object { - val TEMPLATE = """ - - - - - - - {{title}} - - - {{#content}}{{>innerHtml}}{{/content}} - - - """.trimIndent() - } -} - - diff --git a/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/User.kt b/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Simple.kt similarity index 81% rename from benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/User.kt rename to benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Simple.kt index 44c20de..5e74b46 100644 --- a/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/User.kt +++ b/benchmark/src/commonMain/kotlin/net/orandja/ktm/benchmark/Simple.kt @@ -3,7 +3,7 @@ package net.orandja.ktm.benchmark import net.orandja.ktm.ksp.KtmContext @KtmContext -data class User( +data class Simple( val firstName: String, val lastName: String, ) { @@ -12,7 +12,7 @@ data class User( User: {{ firstName }} {{ lastName }} """.trimIndent() - val CONTEXT = User("John", "doe") + val CONTEXT = Simple("John", "doe") } } diff --git a/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/WinnerBenchmark.kt b/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/ComplexBenchmark.kt similarity index 77% rename from benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/WinnerBenchmark.kt rename to benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/ComplexBenchmark.kt index a2a14a0..ba4d725 100644 --- a/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/WinnerBenchmark.kt +++ b/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/ComplexBenchmark.kt @@ -8,7 +8,7 @@ import net.orandja.ktm.base.MDocument @State(Scope.Benchmark) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(BenchmarkTimeUnit.NANOSECONDS) -class WinnerBenchmark { +class ComplexBenchmark { lateinit var LBriandTemplate: MDocument lateinit var SpullaraTemplate: Mustache @@ -21,15 +21,15 @@ class WinnerBenchmark { } @Benchmark - fun LBriandKtmParse() = LBriandKtm.compile(Winner.TEMPLATE) + fun LBriandKtmParse() = LBriandKtm.compile(Complex.TEMPLATE) @Benchmark - fun SpullaraMustacheParse() = SpullaraMustache.compile(Winner.TEMPLATE) + fun SpullaraMustacheParse() = SpullaraMustache.compile(Complex.TEMPLATE) @Benchmark - fun LBriandKtmRender() = LBriandKtm.render(LBriandTemplate, Winner.CONTEXT) + fun LBriandKtmRender() = LBriandKtm.render(LBriandTemplate, Complex.CONTEXT) @Benchmark - fun SpullaraMustacheRender() = SpullaraMustache.render(SpullaraTemplate, Winner.CONTEXT) + fun SpullaraMustacheRender() = SpullaraMustache.render(SpullaraTemplate, Complex.CONTEXT) } \ No newline at end of file diff --git a/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/WinnersBenchmark.kt b/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/MultiComplexBenchmark.kt similarity index 74% rename from benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/WinnersBenchmark.kt rename to benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/MultiComplexBenchmark.kt index 84469cc..704802f 100644 --- a/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/WinnersBenchmark.kt +++ b/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/MultiComplexBenchmark.kt @@ -8,7 +8,7 @@ import net.orandja.ktm.base.MDocument @State(Scope.Benchmark) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(BenchmarkTimeUnit.NANOSECONDS) -class WinnersBenchmark { +class MultiComplexBenchmark { lateinit var LBriandTemplate: MDocument lateinit var SpullaraTemplate: Mustache @@ -21,27 +21,27 @@ class WinnersBenchmark { } @Benchmark - fun LBriandKtmParse() = LBriandKtm.compile(Winners.TEMPLATE) + fun LBriandKtmParse() = LBriandKtm.compile(Multiple.TEMPLATE) @Benchmark - fun SpullaraMustacheParse() = SpullaraMustache.compile(Winners.TEMPLATE) + fun SpullaraMustacheParse() = SpullaraMustache.compile(Multiple.TEMPLATE) @Benchmark - fun LBriandKtmRenderX01() = LBriandKtm.render(LBriandTemplate, Winners.CONTEXT_X01) + fun LBriandKtmRenderX01() = LBriandKtm.render(LBriandTemplate, Multiple.CONTEXT_X01) @Benchmark - fun SpullaraMustacheRenderX01() = SpullaraMustache.render(SpullaraTemplate, Winners.CONTEXT_X01) + fun SpullaraMustacheRenderX01() = SpullaraMustache.render(SpullaraTemplate, Multiple.CONTEXT_X01) @Benchmark - fun LBriandKtmRenderX10() = LBriandKtm.render(LBriandTemplate, Winners.CONTEXT_X10) + fun LBriandKtmRenderX10() = LBriandKtm.render(LBriandTemplate, Multiple.CONTEXT_X10) @Benchmark - fun SpullaraMustacheRenderX10() = SpullaraMustache.render(SpullaraTemplate, Winners.CONTEXT_X10) + fun SpullaraMustacheRenderX10() = SpullaraMustache.render(SpullaraTemplate, Multiple.CONTEXT_X10) @Benchmark - fun LBriandKtmRenderX50() = LBriandKtm.render(LBriandTemplate, Winners.CONTEXT_X50) + fun LBriandKtmRenderX50() = LBriandKtm.render(LBriandTemplate, Multiple.CONTEXT_X50) @Benchmark - fun SpullaraMustacheRenderX50() = SpullaraMustache.render(SpullaraTemplate, Winners.CONTEXT_X50) + fun SpullaraMustacheRenderX50() = SpullaraMustache.render(SpullaraTemplate, Multiple.CONTEXT_X50) } \ No newline at end of file diff --git a/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/UserBenchmark.kt b/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/SimpleBenchmark.kt similarity index 77% rename from benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/UserBenchmark.kt rename to benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/SimpleBenchmark.kt index 3be6b48..dd511ff 100644 --- a/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/UserBenchmark.kt +++ b/benchmark/src/jvmMain/kotlin/net.orandja.ktm.benchmark/SimpleBenchmark.kt @@ -8,7 +8,7 @@ import net.orandja.ktm.base.MDocument @State(Scope.Benchmark) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(BenchmarkTimeUnit.NANOSECONDS) -class UserBenchmark { +class SimpleBenchmark { lateinit var LBriandTemplate: MDocument lateinit var SpullaraTemplate: Mustache @@ -21,15 +21,15 @@ class UserBenchmark { } @Benchmark - fun LBriandKtmParse() = LBriandKtm.compile(User.TEMPLATE) + fun LBriandKtmParse() = LBriandKtm.compile(Simple.TEMPLATE) @Benchmark - fun SpullaraMustacheParse() = SpullaraMustache.compile(User.TEMPLATE) + fun SpullaraMustacheParse() = SpullaraMustache.compile(Simple.TEMPLATE) @Benchmark - fun LBriandKtmRender() = LBriandKtm.render(LBriandTemplate, User.CONTEXT) + fun LBriandKtmRender() = LBriandKtm.render(LBriandTemplate, Simple.CONTEXT) @Benchmark - fun SpullaraMustacheRender() = SpullaraMustache.render(SpullaraTemplate, User.CONTEXT) + fun SpullaraMustacheRender() = SpullaraMustache.render(SpullaraTemplate, Simple.CONTEXT) } \ No newline at end of file diff --git a/benchmark/src/jvmTest/kotlin/net/orandja/ktm/benchmark/EqualityCheck.kt b/benchmark/src/jvmTest/kotlin/net/orandja/ktm/benchmark/EqualityCheck.kt index fc66442..69bee08 100644 --- a/benchmark/src/jvmTest/kotlin/net/orandja/ktm/benchmark/EqualityCheck.kt +++ b/benchmark/src/jvmTest/kotlin/net/orandja/ktm/benchmark/EqualityCheck.kt @@ -15,7 +15,7 @@ class EqualityCheck { @Test fun `User Check`() { - with(UserBenchmark()) { + with(SimpleBenchmark()) { setup() assertEquals(LBriandKtmRender(), SpullaraMustacheRender()) } @@ -23,7 +23,7 @@ class EqualityCheck { @Test fun `Winner Check`() { - with(WinnerBenchmark()) { + with(ComplexBenchmark()) { setup() assertEquals(LBriandKtmRender(), SpullaraMustacheRender()) } @@ -31,7 +31,7 @@ class EqualityCheck { @Test fun `Winners x1 Check`() { - with(WinnersBenchmark()) { + with(MultiComplexBenchmark()) { setup() assertEquals(LBriandKtmRenderX01(), SpullaraMustacheRenderX01()) } @@ -39,7 +39,7 @@ class EqualityCheck { @Test fun `Winners x10 Check`() { - with(WinnersBenchmark()) { + with(MultiComplexBenchmark()) { setup() assertEquals(LBriandKtmRenderX10(), SpullaraMustacheRenderX10()) } @@ -47,7 +47,7 @@ class EqualityCheck { @Test fun `Winners x50 Check`() { - with(WinnersBenchmark()) { + with(MultiComplexBenchmark()) { setup() assertEquals(LBriandKtmRenderX50(), SpullaraMustacheRenderX50()) } diff --git a/core/src/commonMain/kotlin/net/orandja/ktm/ExtensionKtmAdapter.kt b/core/src/commonMain/kotlin/net/orandja/ktm/ExtensionKtmAdapter.kt index 76f763c..92922a6 100644 --- a/core/src/commonMain/kotlin/net/orandja/ktm/ExtensionKtmAdapter.kt +++ b/core/src/commonMain/kotlin/net/orandja/ktm/ExtensionKtmAdapter.kt @@ -26,8 +26,7 @@ class NoProviderException(type: KType) : IllegalArgumentException( @Throws(NoProviderException::class) @Suppress("UNCHECKED_CAST") inline fun KtmAdapter.Provider.get(): KtmAdapter? { - val kType = typeOf() - return get(kType) as? KtmAdapter + return get(typeOf()) as? KtmAdapter } diff --git a/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmContext.kt b/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmContext.kt index 301cb7c..2a7b4c8 100644 --- a/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmContext.kt +++ b/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmContext.kt @@ -20,7 +20,6 @@ import net.orandja.ktm.base.MContext * ``` * * @see KtmName - * @see KtmDynamic */ @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.SOURCE) diff --git a/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmDynamic.kt b/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmDynamic.kt deleted file mode 100644 index 7e047e7..0000000 --- a/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmDynamic.kt +++ /dev/null @@ -1,28 +0,0 @@ -package net.orandja.ktm.ksp - -/** - * This annotation can be used to indicate whether a field in a [KtmContext] dynamic or not. - * - * Example: - * ```kotlin - * @KtmContext - * class Data( - * @KtmDynamic - * var foo: String, - * var bar: String, - * var baz: String - * ) - * - * val context = Data("a", "b", "c") - * val template = "{{ foo }} - {{ bar }} - {{ baz }}" - * template.render(context) // a - b - c - * context.apply { a = "1"; b = "2"; c = "3" } - * template.render(context) // 1 - b - c - * ``` - * - * @see KtmContext - * @see KtmName - */ -@Target(AnnotationTarget.PROPERTY) -@Retention(AnnotationRetention.SOURCE) -annotation class KtmDynamic diff --git a/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmIgnore.kt b/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmIgnore.kt index 62d2263..66a29ff 100644 --- a/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmIgnore.kt +++ b/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmIgnore.kt @@ -18,7 +18,6 @@ package net.orandja.ktm.ksp * ``` * * @see KtmContext - * @see KtmDynamic */ @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.SOURCE) diff --git a/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmName.kt b/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmName.kt index 5297751..30c737d 100644 --- a/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmName.kt +++ b/core/src/commonMain/kotlin/net/orandja/ktm/ksp/KtmName.kt @@ -19,7 +19,6 @@ package net.orandja.ktm.ksp * @param name The name of the element (empty to keep field name) * * @see KtmContext - * @see KtmDynamic */ @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.SOURCE) diff --git a/core/src/commonTest/kotlin/net/orandja/ktm/test/EnumTransformationTest.kt b/core/src/commonTest/kotlin/net/orandja/ktm/test/EnumTransformationTest.kt index b4b377d..61a78b8 100644 --- a/core/src/commonTest/kotlin/net/orandja/ktm/test/EnumTransformationTest.kt +++ b/core/src/commonTest/kotlin/net/orandja/ktm/test/EnumTransformationTest.kt @@ -21,7 +21,7 @@ class EnumTransformationTest { assertEquals("", "{{# values }}<{{.}}>{{/ values }}".render(context)) } - val CustomAdapter = KtmAdapter { adapters, value -> + private val customAdapter = KtmAdapter { _, value -> Ktm.ctx.make { when (value) { EnumVariants.FOO -> "FOO" by "A" @@ -33,7 +33,7 @@ class EnumTransformationTest { @Test fun testContextAdapter() { - val adapters = Ktm.adapters.make { +CustomAdapter } + val adapters = Ktm.adapters.make { +customAdapter } val context = EnumVariants.FOO.toMustacheContext(adapters) assertEquals("A", "{{ FOO }}".render(context)) assertEquals("", "{{ BAR }}".render(context)) diff --git a/ksp-sample/src/commonMain/kotlin/net/orandja/ktm/ksp/sample/NormalCase.kt b/ksp-sample/src/commonMain/kotlin/net/orandja/ktm/ksp/sample/NormalCase.kt index 0a45db9..fc55eb3 100644 --- a/ksp-sample/src/commonMain/kotlin/net/orandja/ktm/ksp/sample/NormalCase.kt +++ b/ksp-sample/src/commonMain/kotlin/net/orandja/ktm/ksp/sample/NormalCase.kt @@ -2,7 +2,6 @@ package net.orandja.ktm.ksp.sample import net.orandja.ktm.base.NodeContext import net.orandja.ktm.ksp.KtmContext -import net.orandja.ktm.ksp.KtmDynamic import net.orandja.ktm.ksp.KtmIgnore import net.orandja.ktm.ksp.KtmName @@ -17,11 +16,10 @@ class ClassWithInner { data class ClassWithProperty( val foo: String = "foo", @KtmName("bar") - val bah: String = "bar", + var bah: String = "bar", ) { private var _count = 0 - @KtmDynamic val count get() = (_count++) } diff --git a/ksp-sample/src/jvmTest/kotlin/net/orandja/ktm/ksp/sample/NormalCaseTest.kt b/ksp-sample/src/jvmTest/kotlin/net/orandja/ktm/ksp/sample/NormalCaseTest.kt index ee9a932..9cc5eff 100644 --- a/ksp-sample/src/jvmTest/kotlin/net/orandja/ktm/ksp/sample/NormalCaseTest.kt +++ b/ksp-sample/src/jvmTest/kotlin/net/orandja/ktm/ksp/sample/NormalCaseTest.kt @@ -18,12 +18,15 @@ class NormalCaseTest { @Test fun propertyClass() { - val context = AutoKtmAdaptersModule.createAdapters().contextOf(ClassWithProperty()) + val data = ClassWithProperty() + val context = AutoKtmAdaptersModule.createAdapters().contextOf(data) assertEquals("foo", "{{ foo }}".render(context)) assertEquals("bar", "{{ bar }}".render(context)) assertEquals("0", "{{ count }}".render(context)) assertEquals("1", "{{ count }}".render(context)) assertEquals("", "{{ _count }}".render(context)) + data.bah = "bah" + assertEquals("bah", "{{ bar }}".render(context)) } @Test diff --git a/ksp/src/main/kotlin/net/orandja/ktm/ksp/generation/AdapterToken.kt b/ksp/src/main/kotlin/net/orandja/ktm/ksp/generation/AdapterToken.kt index 62c5dac..47926e7 100644 --- a/ksp/src/main/kotlin/net/orandja/ktm/ksp/generation/AdapterToken.kt +++ b/ksp/src/main/kotlin/net/orandja/ktm/ksp/generation/AdapterToken.kt @@ -99,15 +99,17 @@ sealed class AdapterToken(val kind: Kind) { data object {{ sanitized_simple_name }}KtmAdapter : KtmAdapter<{{ simple_name }}{{{ type_parameter }}}> { override fun toString(): String = "{{ simple_name }}KtmAdapter" - override fun toMustacheContext(adapters: KtmAdapter.Provider, value: {{ simple_name }}{{{ type_parameter }}}): MContext = - MContext.Map { _, tag -> - when (tag) { - {{# fields }} - {{> _class_field }} - {{/fields}} - else -> null - } + override fun toMustacheContext( + adapters: KtmAdapter.Provider, + value: {{ simple_name }}{{{ type_parameter }}} + ): MContext = MContext.Map { _, tag -> + when (tag) { + {{# fields }} + {{> _class_field }} + {{/fields}} + else -> null } + } } """.trimIndent() } @@ -117,7 +119,6 @@ sealed class AdapterToken(val kind: Kind) { val name: String, val fieldName: String, val isCallable: Boolean, - val isDynamic: Boolean, val nodeAsParameter: Boolean, val nodeAsReceiver: Boolean, val isFunction: Boolean, @@ -129,7 +130,6 @@ sealed class AdapterToken(val kind: Kind) { "name" by value.name "fieldName" by value.fieldName "isCallable" by value.isCallable - "isDynamic" by if (value.isCallable) false else value.isDynamic "isFunction" by value.isFunction "node" by (value.nodeAsParameter || value.nodeAsReceiver) "nodeReceiver" by (value.isCallable && value.isFunction && value.nodeAsReceiver) @@ -146,11 +146,7 @@ sealed class AdapterToken(val kind: Kind) { "{{^nodeReceiver}}$context{{/nodeReceiver}}" @Language("mustache") - private val dynamic = - "{{#isDynamic}}Ktm.ctx.delegate { {{/isDynamic}}$nodeReceiverEdgeCase{{#isDynamic}} }{{/isDynamic}}" - - @Language("mustache") - val Template = "\"{{name}}\" -> $dynamic\n" + val Template = "\"{{name}}\" -> $nodeReceiverEdgeCase\n" } } } diff --git a/ksp/src/main/kotlin/net/orandja/ktm/ksp/visitor/TokenBuilderVisitor.kt b/ksp/src/main/kotlin/net/orandja/ktm/ksp/visitor/TokenBuilderVisitor.kt index 5fabf2a..5b45478 100644 --- a/ksp/src/main/kotlin/net/orandja/ktm/ksp/visitor/TokenBuilderVisitor.kt +++ b/ksp/src/main/kotlin/net/orandja/ktm/ksp/visitor/TokenBuilderVisitor.kt @@ -97,18 +97,13 @@ class TokenBuilderVisitor(private val ktmLogger: KtmLogger) : // Name surcharge with @KtmName val ktmName = property.annotations.getKtmName(data) - var isDynamic = false var isCallable = false var isNodeAsParameter = false var isNodeAsReceiver = false var isFunction = false when (typeInformation) { - is Classifier -> { - // Use of delegate context function with @KtmDynamic - isDynamic = property.annotations.isKtmDynamic(data) - } - + is Classifier -> {} is Callable -> { isCallable = true isNodeAsParameter = typeInformation.isNodeAsParameter @@ -128,7 +123,6 @@ class TokenBuilderVisitor(private val ktmLogger: KtmLogger) : name = ktmName ?: name, fieldName = name, isCallable = isCallable, - isDynamic = isDynamic, nodeAsParameter = isNodeAsParameter, nodeAsReceiver = isNodeAsReceiver, isFunction = isFunction, @@ -270,7 +264,6 @@ class TokenBuilderVisitor(private val ktmLogger: KtmLogger) : name = ktmName ?: name, fieldName = name, isCallable = true, - isDynamic = false, // Functions are by default dynamic. nodeAsParameter = isNodeParameter, nodeAsReceiver = isNodeReceiver, isFunction = true,