Code covered by the BSD License  

Highlights from
JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave

image thumbnail

JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave

by

Qianqian Fang (view profile)

  • 1 file
  • 515 downloads
  • 4.39286

 

19 Oct 2011 (Updated )

JSONlab is an open-source JSON/UBJSON encoder and decoder for MATLAB and Octave.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

jsonlab_speedtest.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%         Benchmarking processing speed of savejson and loadjson
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

datalen=[1e3 1e4 1e5 1e6];
len=length(datalen);
tsave=zeros(len,1);
tload=zeros(len,1);
for i=1:len
    tic;
    json=savejson('data',struct('d1',rand(datalen(i),3),'d2',rand(datalen(i),3)>0.5));
    tsave(i)=toc;
    data=loadjson(json);
    tload(i)=toc-tsave(i);
    fprintf(1,'matrix size: %d\n',datalen(i));
end

loglog(datalen,tsave,'o-',datalen,tload,'r*-');
legend('savejson runtime (s)','loadjson runtime (s)');
xlabel('array size');
ylabel('running time (s)');

Contact us