Replies: 4 comments
-
Same benchmark for a small file (tests/data/test.json). Here MIDI and note-seq (protocol buffer) clearly win over compressed formats in terms of size. %timeit music.write_midi(out_path.with_suffix('.mid'))
%timeit music.save(out_path.with_suffix('.json'))
%%timeit
with open(out_path.with_suffix('.bson'), 'wb') as f:
f.write(bson.dumps(music.to_ordered_dict()))
%%timeit
with gzip.open(out_path.with_suffix('.json.gz'), 'wt') as f:
json.dump(music.to_ordered_dict(), f)
%%timeit
with lzma.open(out_path.with_suffix('.json.xz'), 'wt') as f:
json.dump(music.to_ordered_dict(), f)
%timeit music.save(out_path.with_suffix('.yaml'))
%%timeit
with open(out_path.with_suffix('.muspy.pkl'), 'wb') as f:
pickle.dump(music, f)
%%timeit
with open(out_path.with_suffix('.note-seq.bin'), 'wb') as f:
f.write(note_seq.midi_to_sequence_proto(music.to_pretty_midi()).SerializeToString())
!ls -lSrh {testdir}
|
Beta Was this translation helpful? Give feedback.
-
This is interesting. Thanks for testing this. Our main reason to choose JSON and YAML is for readability. However, it would be also great to support other formats for speed and memory reason. Some ideas:
|
Beta Was this translation helpful? Give feedback.
-
A great first step would be to allow passing open files instead of paths to
Yes, though this is not lossless. BTW, I also tested read speed. The results are similar, except that:
|
Beta Was this translation helpful? Give feedback.
-
One more idea: an |
Beta Was this translation helpful? Give feedback.
-
Below is a little benchmark of the efficiency of YAML, JSON and other representations on a file from NES-MDB.
Wow!
Conclusion: Support for gzipped JSON should be added 🙂
Beta Was this translation helpful? Give feedback.
All reactions