Time complexity of JSON serialization/parse
I've benchmarked the time complexity with this code:
import jsonimport randomimport timeNs = 10, 100, 1000, 10000, 100000, 200000, 300000, 600000, 1000000for N in Ns: l = [random.random() for i in xrange(N)] t0 = time.time() s = json.dumps(l) t1 = time.time() dt = t1-t0 print "%s %s" % (N, dt)
On my machine, the outcome is:
10 7.20024108887e-05100 0.0003859996795651000 0.0036280155181910000 0.036504983902100000 0.366562128067200000 0.73614192009300000 1.09785795212600000 2.202728033071000000 3.6590487957
First column: list length; second column: time for serialization. Plotting (with for example xmgrace) reveals an ideal linear relation.