Skip to content

Why is toJSON slow in jsonlite? #1

@ramnathv

Description

@ramnathv

I did a quick benchmark of speeds of toJSON conversions across packages. Here is the code

library(microbenchmark)
microbenchmark(
  jsonlite::toJSON(mtcars),
  RJSONIO::toJSON(mtcars),
  rjson::toJSON(mtcars),
  times = 10
)

The results seem to indicate that jsonlite is much slower as compared to the other two packages. Is this because of the more verbose serialization?

Unit: microseconds
                     expr        min         lq      median         uq        max neval
 jsonlite::toJSON(mtcars) 137884.341 142062.506 145352.0815 150982.395 177053.330    10
  RJSONIO::toJSON(mtcars)   1187.170   1280.926   1301.4975   1487.285   2240.849    10
    rjson::toJSON(mtcars)    226.272    230.432    271.4605    275.248    325.430    10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions