Speed up writing to files

后端 未结 3 1934
醉梦人生
醉梦人生 2020-12-03 05:20

I\'ve profiled some legacy code I\'ve inherited with cProfile. There were a bunch of changes I\'ve already made that have helped (like using simplejson\'s C extensions!).

3条回答
  •  孤城傲影
    2020-12-03 05:50

    Batching the writes into groups of 500 did indeed speed up the writes significantly. For this test case the writing rows individually took 21.051 seconds in I/O, while writing in batches of 117 took 5.685 seconds to write the same number of rows. Batches of 500 took a total of only 0.266 seconds.

提交回复
热议问题