Skip to content

Commit

Permalink
add midifile to benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Yikai-Liao committed Jan 4, 2024
1 parent 6bfb70a commit 2ce20ab
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# symusic
# [symusic](https://github.com/Yikai-Liao/symusic)
[![Build and upload to PyPI](https://github.com/Yikai-Liao/symusic/actions/workflows/wheel.yml/badge.svg?branch=main)](https://github.com/Yikai-Liao/symusic/actions/workflows/wheel.yml) [![PyPI version](https://badge.fury.io/py/symusic.svg)](https://badge.fury.io/py/symusic) [![Downloads](https://static.pepy.tech/badge/symusic)](https://pepy.tech/project/symusic) [![Page Views Count](https://badges.toozhao.com/badges/01HGE1345YAKN4YV7WF0JRKZJK/blue.svg)](https://badges.toozhao.com/stats/01HGE1345YAKN4YV7WF0JRKZJK "Get your own page views count badge on badges.toozhao.com") <a target="_blank" href="https://colab.research.google.com/github/Yikai-Liao/symusic/blob/main/tutorial.ipynb">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
Expand Down Expand Up @@ -52,21 +52,26 @@ pip install ./symusic
### Parsing MIDI

* test using [mahler.mid](https://github.com/lzqlzzq/minimidi/blob/main/example/mahler.mid) from minimidi/example on my laptop (i7-10875H, 32GB 2666MHz DDR4 RAM, Linux 6.1.69-1-lts)
* `midifile` is writen in cpp, and could parse midi files to both `event level` and `note level`. It is slow mostly becuase of `iostream`.
* `mido` is writen in pure python, and only parses midi files to `event level`
* `pretty_midi` and `miditoolkit` is based on `mido`, and parse midi files to `note level`

| library | absolute time | relative time |
|-----------------------------------------------------------|-------------------|-------------------|
| [**symusic**](https://github.com/Yikai-Liao/symusic) | 3.47 ms ± 113 µs | 1.0x |
| [MIDI.jl](https://github.com/JuliaMusic/MIDI.jl) | 109.707 ms | 31.6x |
| [mido](https://github.com/mido/mido) | 2.92 s ± 42.7 ms | 841.5x |
| [miditoolkit](https://github.com/YatingMusic/miditoolkit) | 3.15 s ± 38.2 ms | 907.7x |
| [pretty_midi](https://github.com/craffel/pretty-midi) | 3.16 s ± 9.56 ms | 910.7x |
| [music21](https://github.com/cuthbertLab/music21) | 4.23 s ± 34.5 ms | 1219.0x |
* For libraries written in python or with python bindings, we use `timeit` to measure the time cost of parsing the midi file. `nanobench` for cpp libraries and `BenchmarkTools` for julia libraries.

| library | level | absolute time | relative time |
|---------------------------------------------------------------|-------|-------------------|---------------|
| [**minimidi**](https://github.com/lzqlzzq/minimidi) | event | 2.86 ms | 1.0x |
| [**symusic**](https://github.com/Yikai-Liao/symusic) | note | 3.47 ms ± 113 µs | 1.2x |
| [midifile](https://github.com/craigsapp/midifile) | event | 44.0 ms | 15.4x |
| [midifile](https://github.com/craigsapp/midifile) | note | 45.6 ms | 15.9x |
| [MIDI.jl](https://github.com/JuliaMusic/MIDI.jl) | note | 109.707 ms | 38.4x |
| [mido](https://github.com/mido/mido) | event | 2.92 s ± 42.7 ms | 1021.0x |
| [miditoolkit](https://github.com/YatingMusic/miditoolkit) | note | 3.15 s ± 38.2 ms | 1101.4x |
| [pretty_midi](https://github.com/craffel/pretty-midi) | note | 3.16 s ± 9.56 ms | 1104.9x |
| [music21](https://github.com/cuthbertLab/music21) | note | 4.23 s ± 34.5 ms | 1479.0x |

## Acknowledgement

* [minimidi](https://github.com/lzqlzzq/minimidi/tree/main) : A fast and lightweight midi parsing library written in cpp, which is the foundation of this project.
* [minimidi](https://github.com/lzqlzzq/minimidi) : A fast and lightweight midi parsing library written in cpp, which is the foundation of this project.
* [pybind11](https://github.com/pybind/pybind11) : A great header-only library to help you create python binding for your cpp code.
* [pybind11-stubgen](https://github.com/sizmailov/pybind11-stubgen) A nice tool to generate stub files for pybind11 projects.
* [zpp_bits](https://github.com/eyalz800/zpp_bits) : An extraordinary fast and lightweight single header library for serialization and deserialization. I use it to support pickle.
Expand Down

0 comments on commit 2ce20ab

Please sign in to comment.