-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
I'm seeing a 10x slowdown on first JSON3 parse, and a 3x on subsequent parses when comparing JSON.jl v1 (commit ecda14d) with JSON3 v1.14.3. That is not ideal, since parsing JSON is a bottleneck in my program.
To reproduce:
- Make an environment with JSON.jl commit ecda14d and JSON3.jl v1.14.3
- Download the attached gzip file, and decompress it in your directory
- Run the script below, switching the boolean
@static if false
between runs (I used Julia 1.12.0-rc1)
Timings on my computer:
JSON3:
first_time = 0.408839696
mean_time = 0.20233652939999996
JSON v1
first_time = 4.310216864
mean_time = 0.6266064803999999
File
Script
const GENOMES_JSON_T = Vector{Tuple{String, Int, Vector{Tuple{String, Int}}}}
const SEQUENCES_JSON_T = Vector{Tuple{String, Int, Vector{Tuple{String, Int, Int}}}}
const TAXMAPS_JSON_T = Vector{Vector{Tuple{String, String}}}
struct ReferenceJSON
version::Int
genomes::GENOMES_JSON_T
sequences::SEQUENCES_JSON_T
taxmaps::TAXMAPS_JSON_T
end
s = read("reference.json", String)
f = @static if true # change to switch JSON versions
using JSON
JSON.parse
else
using JSON3
JSON3.parse
end
first_time = (@timed f(s, ReferenceJSON)).time
@show first_time
y = 0.0
for _ in 1:10
global y += (@timed f(s, ReferenceJSON)).time
end
mean_time = y / 10
@show mean_time
Metadata
Metadata
Assignees
Labels
No labels