Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try JSON3 #32

Open
mmiller-max opened this issue Aug 9, 2021 · 1 comment
Open

Try JSON3 #32

mmiller-max opened this issue Aug 9, 2021 · 1 comment

Comments

@mmiller-max
Copy link
Contributor

I think JSON3 could bring some speed improvements, and we could possibly make use of StructTypes to help read OSM graph straight into an OSMGraph, maybe

@mmiller-max
Copy link
Contributor Author

Using a 1km map centred on Melbourne, JSON looks quickest and has fewer allocations. It is twice as quick as xml so I think we should be recommending this in docs/tutorial @captchanjack ?

Graph download in two formats:

julia> data = download_osm_network(:place_name,
                                   place_name="melbourne, australia",
                                   network_type=:drive,download_format=:json,
                                   save_to_file_location="melbourne_drive_network.json");
julia> data = download_osm_network(:place_name,
                                   place_name="melbourne, australia",
                                   network_type=:drive,download_format=:osm,
                                   save_to_file_location="melbourne_drive_network.osm");

JSON benchmark

julia> @benchmark graph_from_file($("melbourne_1k.json"))
BenchmarkTools.Trial: 1075 samples with 1 evaluation.
 Range (min … max):  4.066 ms … 51.116 ms  ┊ GC (min … max): 0.00% … 88.51%
 Time  (median):     4.289 ms              ┊ GC (median):    0.00%
 Time  (mean ± σ):   4.640 ms ±  3.445 ms  ┊ GC (mean ± σ):  5.38% ±  6.61%

    ▆█▆▂                                                      
  ▆███████▅▅▅▆▆█▇▅▆▆▇▄▃▃▃▃▂▃▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▁▂▂▂▁▁▁▂▁▂▁▁▁▂ ▃
  470 ms         Histogram: frequency by time        5.79 ms <

 Memory estimate: 4.20 MiB, allocs estimate: 43720.

JSON3 benchmark (deserializer = (file) -> JSON3.read(open(file), Dict))

julia> @benchmark graph_from_file($("melbourne_1k.json"))
BenchmarkTools.Trial: 1046 samples with 1 evaluation.
 Range (min … max):  4.135 ms … 52.044 ms  ┊ GC (min … max): 0.00% … 84.64%
 Time  (median):     4.445 ms              ┊ GC (median):    0.00%
 Time  (mean ± σ):   4.768 ms ±  3.524 ms  ┊ GC (mean ± σ):  5.22% ±  6.43%

    ▅▇█▅▂     ▂ ▁▁▁                                           
  ▄▇███████▅▆██▇███▇▅▅▄▄▄▃▅▃▄▃▄▂▃▃▂▃▂▂▂▂▃▂▂▂▂▁▂▂▂▁▂▁▁▁▁▁▂▁▁▂ ▄
  4.14 ms        Histogram: frequency by time        5.92 ms <

 Memory estimate: 4.50 MiB, allocs estimate: 56697.

OSM/XML benchmark:

julia> @benchmark graph_from_file($("melbourne_1k.osm"))
BenchmarkTools.Trial: 495 samples with 1 evaluation.
 Range (min … max):   8.902 ms … 58.372 ms  ┊ GC (min … max): 0.00% … 82.90%
 Time  (median):      9.318 ms              ┊ GC (median):    0.00%
 Time  (mean ± σ):   10.095 ms ±  4.554 ms  ┊ GC (mean ± σ):  3.85% ±  7.46%

  ▆▇█▇▃▁                                                       
  ██████▇▅▄▇▅▆▇▆▁▅▁▄▄▅▁▄▆▁▁▄▁▁▁▁▄▁▅▁▁▁▄▄▄▁▄▆▆▁▄▄▁▁▄▁▁▁▁▁▁▁▁▁▅ ▇
  8.9 ms       Histogram: log(frequency) by time      19.1 ms <

 Memory estimate: 6.58 MiB, allocs estimate: 75138.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant