RJSONIO vs rjson - better tuning

前端 未结 2 678
一生所求
一生所求 2021-02-19 00:47

UPDATE:

The tl;dr is that RJSONIO is no longer the faster of the two options. Rather rjson is now much faste

相关标签:
2条回答
  • 2021-02-19 01:04
    > library('BBmisc')
    > suppressAll(lib(c('RJSONIO','rjson','jsonlite','microbenchmark')))
    > U <- toJSON(list(1:10, LETTERS, letters, rnorm(20)))
    > microbenchmark(
    +     rjson::toJSON(U),
    +     RJSONIO::toJSON(U),
    +     jsonlite::toJSON(U, dataframe = "column"),
    +     times = 10
    + )
    Unit: microseconds
                                          expr     min      lq      mean   median      uq       max neval cld
                              rjson::toJSON(U)  65.174  68.767 2002.7007  88.2675 103.151 19179.224    10   a
                            RJSONIO::toJSON(U) 299.186 304.832  482.8038 329.7210 493.683  1351.727    10   a
     jsonlite::toJSON(U, dataframe = "column") 485.985 501.381  555.4192 548.5935 587.083   708.708    10   a
    

    Testing system.time()

    > microbenchmark(
    +     system.time(rjson::toJSON(U)),
    +     system.time(RJSONIO::toJSON(U)),
    +     system.time(jsonlite::toJSON(U, dataframe = "column")),
    +     times = 10)
    Unit: milliseconds
                                                       expr      min       lq     mean   median       uq      max neval cld
                              system.time(rjson::toJSON(U)) 112.0660 115.8677 119.8426 119.8372 121.6908 132.2111    10  ab
                            system.time(RJSONIO::toJSON(U)) 115.4223 118.0262 129.2758 120.5690 148.5175 151.6874    10   b
     system.time(jsonlite::toJSON(U, dataframe = "column")) 113.2674 114.9096 118.0905 117.8401 120.9626 123.6784    10  a
    

    Below are comparison of few packages. Hope these links help...

    1) New package: jsonlite. A smart(er) JSON encoder/decoder.

    2) Improved memory usage and RJSONIO compatibility in jsonlite 0.9.15

    3) A biased comparsion of JSON packages in R

    0 讨论(0)
  • 2021-02-19 01:18

    https://cran.r-project.org/web/packages/jsonlite/vignettes/json-aaquickstart.html

    Please try jsonlite its the fastest in my experience for json data especially nested

    also see

    https://rstudio-pubs-static.s3.amazonaws.com/31702_9c22e3d1a0c44968a4a1f9656f1800ab.html

    0 讨论(0)
提交回复
热议问题