Skip to content

Instantly share code, notes, and snippets.

@mbannert
Last active December 15, 2016 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbannert/14e06edd20bbcb56ababbe005c59cda4 to your computer and use it in GitHub Desktop.
Save mbannert/14e06edd20bbcb56ababbe005c59cda4 to your computer and use it in GitHub Desktop.
jsonlite vs rjsonion - can we make jsonlite faster?
library(microbenchmark)
# json test is a character vector of length 2 containing
# both of the json elements given in sample_data.json
microbenchmark(
lite <- lapply(json_test,function(x){
jsonlite::fromJSON(x,simplifyVector = F)
}),
SONIO <- lapply(json_test,function(x){
RJSONIO::fromJSON(x)
})
)
{
"ts_key": "some_data_A",
"ts_data": {
"1999-10-01": "22.62487757",
"2000-01-01": "33.99014778",
"2000-04-01": "41.50197628",
"2000-07-01": "54.50191571",
"2000-10-01": "51.77713737",
"2001-01-01": "48.32214765",
"2001-04-01": "38.15533981",
"2001-07-01": "24.24830262",
"2001-10-01": "-51.31450828",
"2002-01-01": "-49.51830443",
"2002-04-01": "-34.0776699",
"2002-07-01": "-47.81341108",
"2002-10-01": "-101.3207547",
"2003-01-01": "-80.74003795",
"2003-04-01": "-98.69158879",
"2003-07-01": "-89.83208955",
"2003-10-01": "-63.53488372",
"2004-01-01": "-56.05214153",
"2004-04-01": "-26.22180451",
"2004-07-01": "-19.49860724",
"2004-10-01": "-30.91922006",
"2005-01-01": "-28.20037106",
"2005-04-01": "-24.03393025",
"2005-07-01": "-35.31100478",
"2005-10-01": "-33.05164319",
"2006-01-01": "0",
"2006-04-01": "15.46589817",
"2006-07-01": "34.31839847",
"2006-10-01": "41.06280193",
"2007-01-01": "43.56530029",
"2007-04-01": "48.1086324",
"2007-07-01": "43.49056604",
"2007-10-01": "35.71428571",
"2008-01-01": "30.67426401",
"2008-04-01": "2.36294896",
"2008-07-01": "-25.09469697",
"2008-10-01": "-57.4108818",
"2009-01-01": "-63.98503274",
"2009-04-01": "-96.30655586",
"2009-07-01": "-100.2782931",
"2009-10-01": "-74.69654528",
"2010-01-01": "-58.29471733",
"2010-04-01": "-7.358490566",
"2010-07-01": "5.272895467",
"2010-10-01": "15.72617946",
"2011-01-01": "16.65089877",
"2011-04-01": "12.79178338",
"2011-07-01": "-5.096153846",
"2011-10-01": "-41.62679426",
"2012-01-01": "-47.11359404",
"2012-04-01": "-17.66190076",
"2012-07-01": "-24.13793103",
"2012-10-01": "-21.98088619",
"2013-01-01": "-9.739714526",
"2013-04-01": "-6.623735051",
"2013-07-01": "-9.212880143",
"2013-10-01": "2.72479564",
"2014-01-01": "11.82885906",
"2014-04-01": "5.45625588",
"2014-07-01": "6.925207756",
"2014-10-01": "-8.97994769",
"2015-01-01": "0.928505107",
"2015-04-01": "-21.99612403",
"2015-07-01": "-35.59670782",
"2015-10-01": "-29.56273764",
"2016-01-01": "-34.69041561"
},
"ts_frequency": 4
}
{
"ts_key": "more_data_B",
"ts_data": {
"1999-10-01": "29.6566077",
"2000-01-01": "37.33333333",
"2000-04-01": "39.37172775",
"2000-07-01": "44.52405322",
"2000-10-01": "31.32154006",
"2001-01-01": "29.45891784",
"2001-04-01": "12.06185567",
"2001-07-01": "9.799789252",
"2001-10-01": "-59.91735537",
"2002-01-01": "-3.756345178",
"2002-04-01": "4.756980352",
"2002-07-01": "-12.21294363",
"2002-10-01": "-34.5",
"2003-01-01": "-22.89395441",
"2003-04-01": "-28.26961771",
"2003-07-01": "-16.2027833",
"2003-10-01": "-4.015670911",
"2004-01-01": "20.61068702",
"2004-04-01": "24.03100775",
"2004-07-01": "15.03394762",
"2004-10-01": "-3.875968992",
"2005-01-01": "5.152671756",
"2005-04-01": "2.152641879",
"2005-07-01": "-12.46261216",
"2005-10-01": "-11.9140625",
"2006-01-01": "24.52452452",
"2006-04-01": "18.96207585",
"2006-07-01": "24.89959839",
"2006-10-01": "19.46721311",
"2007-01-01": "25.57442557",
"2007-04-01": "30.67484663",
"2007-07-01": "22.03721841",
"2007-10-01": "11.78781925",
"2008-01-01": "-9.190809191",
"2008-04-01": "-19.34846989",
"2008-07-01": "-45.02463054",
"2008-10-01": "-60.50583658",
"2009-01-01": "-57.35150925",
"2009-04-01": "-64.04602109",
"2009-07-01": "-32.62955854",
"2009-10-01": "18.33810888",
"2010-01-01": "23.71916509",
"2010-04-01": "43.94966118",
"2010-07-01": "33.14231137",
"2010-10-01": "18.86255924",
"2011-01-01": "15.04424779",
"2011-04-01": "14.17475728",
"2011-07-01": "-21.6080402",
"2011-10-01": "-37.5502008",
"2012-01-01": "-29.31533269",
"2012-04-01": "-1.977644024",
"2012-07-01": "-19.57720588",
"2012-10-01": "-23.1375986",
"2013-01-01": "-0.255972696",
"2013-04-01": "3.305785124",
"2013-07-01": "-5.621033545",
"2013-10-01": "1.39275766",
"2014-01-01": "17.64705882",
"2014-04-01": "7.830188679",
"2014-07-01": "4.944029851",
"2014-10-01": "-13.50877193",
"2015-01-01": "-12.27573182",
"2015-04-01": "-7.593688363",
"2015-07-01": "-24.71204188",
"2015-10-01": "-15.63106796",
"2016-01-01": "-15.69817866"
},
"ts_frequency": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment