@@ -117,16 +117,35 @@ object BenchmarkRunner {
117117
118118 val json5Result = resultList.find { it.format == " JSON5" }
119119 val jsonResult = resultList.find { it.format == " JSON" }
120+ val externalJson5Result = resultList.find { it.format == " External-JSON5" }
120121
121- if (json5Result != null && jsonResult != null ) {
122- appendLine(" JSON5: ${String .format(" %.3f" , json5Result.averageTimeMillis)} ms avg" )
123- appendLine(" JSON: ${String .format(" %.3f" , jsonResult.averageTimeMillis)} ms avg" )
122+ if (json5Result != null && jsonResult != null && externalJson5Result != null ) {
123+ appendLine(" JSON5: ${String .format(" %.3f" , json5Result.averageTimeMillis)} ms avg" )
124+ appendLine(" JSON: ${String .format(" %.3f" , jsonResult.averageTimeMillis)} ms avg" )
125+ appendLine(" External-JSON5: ${String .format(" %.3f" , externalJson5Result.averageTimeMillis)} ms avg" )
124126
125- val speedup = json5Result.averageTimeMillis / jsonResult.averageTimeMillis
126- if (speedup > 1.0 ) {
127- appendLine(" → JSON is ${String .format(" %.2f" , speedup)} x faster than JSON5" )
127+ // Compare all libraries
128+ val json5VsJson = json5Result.averageTimeMillis / jsonResult.averageTimeMillis
129+ val externalVsJson = externalJson5Result.averageTimeMillis / jsonResult.averageTimeMillis
130+ val json5VsExternal = json5Result.averageTimeMillis / externalJson5Result.averageTimeMillis
131+
132+ appendLine(" Comparisons:" )
133+ if (json5VsJson > 1.0 ) {
134+ appendLine(" → JSON is ${String .format(" %.2f" , json5VsJson)} x faster than JSON5" )
135+ } else {
136+ appendLine(" → JSON5 is ${String .format(" %.2f" , 1.0 / json5VsJson)} x faster than JSON" )
137+ }
138+
139+ if (externalVsJson > 1.0 ) {
140+ appendLine(" → JSON is ${String .format(" %.2f" , externalVsJson)} x faster than External-JSON5" )
141+ } else {
142+ appendLine(" → External-JSON5 is ${String .format(" %.2f" , 1.0 / externalVsJson)} x faster than JSON" )
143+ }
144+
145+ if (json5VsExternal > 1.0 ) {
146+ appendLine(" → External-JSON5 is ${String .format(" %.2f" , json5VsExternal)} x faster than JSON5" )
128147 } else {
129- appendLine(" → JSON5 is ${String .format(" %.2f" , 1.0 / speedup )} x faster than JSON " )
148+ appendLine(" → JSON5 is ${String .format(" %.2f" , 1.0 / json5VsExternal )} x faster than External-JSON5 " )
130149 }
131150 }
132151 appendLine()
@@ -136,18 +155,37 @@ object BenchmarkRunner {
136155 appendLine(" Overall Statistics:" )
137156 val json5Results = results.filter { it.format == " JSON5" }
138157 val jsonResults = results.filter { it.format == " JSON" }
158+ val externalJson5Results = results.filter { it.format == " External-JSON5" }
139159
140160 val avgJson5Time = json5Results.map { it.averageTimeMillis }.average()
141161 val avgJsonTime = jsonResults.map { it.averageTimeMillis }.average()
162+ val avgExternalJson5Time = externalJson5Results.map { it.averageTimeMillis }.average()
142163
143- appendLine(" Average JSON5 time: ${String .format(" %.3f" , avgJson5Time)} ms" )
144- appendLine(" Average JSON time: ${String .format(" %.3f" , avgJsonTime)} ms" )
164+ appendLine(" Average JSON5 time: ${String .format(" %.3f" , avgJson5Time)} ms" )
165+ appendLine(" Average JSON time: ${String .format(" %.3f" , avgJsonTime)} ms" )
166+ appendLine(" Average External-JSON5 time: ${String .format(" %.3f" , avgExternalJson5Time)} ms" )
167+
168+ val json5VsJson = avgJson5Time / avgJsonTime
169+ val externalVsJson = avgExternalJson5Time / avgJsonTime
170+ val json5VsExternal = avgJson5Time / avgExternalJson5Time
171+
172+ appendLine(" \n Overall Comparisons:" )
173+ if (json5VsJson > 1.0 ) {
174+ appendLine(" → JSON is ${String .format(" %.2f" , json5VsJson)} x faster than JSON5" )
175+ } else {
176+ appendLine(" → JSON5 is ${String .format(" %.2f" , 1.0 / json5VsJson)} x faster than JSON" )
177+ }
178+
179+ if (externalVsJson > 1.0 ) {
180+ appendLine(" → JSON is ${String .format(" %.2f" , externalVsJson)} x faster than External-JSON5" )
181+ } else {
182+ appendLine(" → External-JSON5 is ${String .format(" %.2f" , 1.0 / externalVsJson)} x faster than JSON" )
183+ }
145184
146- val overallSpeedup = avgJson5Time / avgJsonTime
147- if (overallSpeedup > 1.0 ) {
148- appendLine(" Overall: JSON is ${String .format(" %.2f" , overallSpeedup)} x faster than JSON5" )
185+ if (json5VsExternal > 1.0 ) {
186+ appendLine(" → External-JSON5 is ${String .format(" %.2f" , json5VsExternal)} x faster than JSON5" )
149187 } else {
150- appendLine(" Overall: JSON5 is ${String .format(" %.2f" , 1.0 / overallSpeedup )} x faster than JSON " )
188+ appendLine(" → JSON5 is ${String .format(" %.2f" , 1.0 / json5VsExternal )} x faster than External-JSON5 " )
151189 }
152190 }
153191
@@ -161,9 +199,10 @@ object BenchmarkRunner {
161199 val (dataType, operation) = key.split(" _" )
162200 val json5Result = resultList.find { it.format == " JSON5" }
163201 val jsonResult = resultList.find { it.format == " JSON" }
202+ val externalJson5Result = resultList.find { it.format == " External-JSON5" }
164203
165- if (json5Result != null && jsonResult != null ) {
166- println (" $dataType $operation : JSON5=${String .format(" %.3f" , json5Result.averageTimeMillis)} ms, JSON=${String .format(" %.3f" , jsonResult.averageTimeMillis)} ms" )
204+ if (json5Result != null && jsonResult != null && externalJson5Result != null ) {
205+ println (" $dataType $operation : JSON5=${String .format(" %.3f" , json5Result.averageTimeMillis)} ms, JSON=${String .format(" %.3f" , jsonResult.averageTimeMillis)} ms, External-JSON5= ${ String .format( " %.3f " , externalJson5Result.averageTimeMillis)} ms " )
167206 }
168207 }
169208 }
0 commit comments