Closed codeZeilen closed 6 months ago
Am 22. August 2023 08:16:16 MESZ schrieb Patrick R @.***>:
With the dedicated Json package, we now have two Json parsers in the base system: Json and WebUtils.
I would suggest removing the WebUtils Json parsing logic and forwarding the requests to Json. There are minor differences between the two parsers. One of the most noticable I discovered so far is how invalid input is handled (Json returns nil, WebUtils throws an Error).
do we have perf numbers for both? -- Sent from a mobile device
First simple benchmark suggests Json is significantly faster.
input := '{
"benchmark_name": "Beispiel-Benchmark",
"system_info": {
"os": "Windows 10",
"cpu": "Intel Core i7-8700K",
"ram": "16 GB"
},
"test_results": [
{
"test_name": "Test 1",
"duration_ms": 1234,
"result": "pass"
},
{
"test_name": "Test 2",
"duration_ms": 5678,
"result": "fail"
}
]
}
'.
object := WebUtils jsonDecode: input readStream.
"DECODE"
[Json readFrom: input readStream] bench
'128,000 per second. 7.81 microseconds per run. 2.23955 % GC time.'
'128,000 per second. 7.78 microseconds per run. 2.05959 % GC time.'
[WebUtils jsonDecode: input readStream] bench
'96,800 per second. 10.3 microseconds per run. 2.61948 % GC time.'
'92,700 per second. 10.8 microseconds per run. 2.71946 % GC time.'
"ENCODE"
[Json render: object] bench
'357,000 per second. 2.8 microseconds per run. 7.71846 % GC time.'
'360,000 per second. 2.78 microseconds per run. 7.69692 % GC time.'
[WebUtils jsonEncode: object] bench
'115,000 per second. 8.73 microseconds per run. 10.77784 % GC time.'
'114,000 per second. 8.8 microseconds per run. 10.69572 % GC time.' ```
Am 22. August 2023 14:56:56 MESZ schrieb Patrick R @.***>:
First simple benchmark suggests Json is significantly faster.
input := '{ "benchmark_name": "Beispiel-Benchmark", "system_info": { "os": "Windows 10", "cpu": "Intel Core i7-8700K", "ram": "16 GB" }, "test_results": [ { "test_name": "Test 1", "duration_ms": 1234, "result": "pass" }, { "test_name": "Test 2", "duration_ms": 5678, "result": "fail" } ] } '. [Json readFrom: input readStream] bench '128,000 per second. 7.81 microseconds per run. 2.23955 % GC time.' '128,000 per second. 7.78 microseconds per run. 2.05959 % GC time.' [WebUtils jsonDecode: input readStream] bench '96,800 per second. 10.3 microseconds per run. 2.61948 % GC time.' '92,700 per second. 10.8 microseconds per run. 2.71946 % GC time.' object := WebUtils jsonDecode: input readStream. [Json render: object] bench '357,000 per second. 2.8 microseconds per run. 7.71846 % GC time.' '360,000 per second. 2.78 microseconds per run. 7.69692 % GC time.' [WebUtils jsonEncode: object] bench '115,000 per second. 8.73 microseconds per run. 10.77784 % GC time.' '114,000 per second. 8.8 microseconds per run. 10.69572 % GC time.' ```
neat!
at its inception, WebClient was meant to also run on other Smalltalks (Pharo, for example), hence webutils.
but since this is now trunk, nuke WebClient Json. -T -- Sent from a mobile device
I would suggest removing the WebUtils Json parsing logic and forwarding the requests to Json.
+1
With the dedicated Json package, we now have two Json parsers in the base system: Json and WebUtils.
I would suggest removing the WebUtils Json parsing logic and forwarding the requests to Json. There are minor differences between the two parsers. One of the most noticable I discovered so far is how invalid input is handled (Json returns nil, WebUtils throws an Error).