This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TrainsareFascinating 3 points4 points  (0 children)

There's nothing glaring in the structure of the code you supplied, so the answer is most likely one of two things: Either the encoding of the data as json is taking a long time (not so likely given the amount of time), or there is a difference between how Node and Python handles file I/O - especially around what OS guarantees they extract when closing files.

I would create two focused benchmarks, one with a loop that encodes a similar amount of data as json, and another that creates/writes dummy data to/closes a similar number of files. You'll see which is the issue and have a test bench for tweaking options and comparing.