Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mido backend is slower than old python-midi backend #102

Open
craffel opened this issue Oct 4, 2016 · 1 comment
Open

mido backend is slower than old python-midi backend #102

craffel opened this issue Oct 4, 2016 · 1 comment

Comments

@craffel
Copy link
Owner

craffel commented Oct 4, 2016

For reference, reading in example.mid takes on average 153 ms with mido backend and 131 ms with python-midi backend. Here are the prun outputs:

mido

         357073 function calls in 0.272 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.037    0.037    0.181    0.181 midifiles.py:299(_read_track)
        1    0.029    0.029    0.040    0.040 pretty_midi.py:218(_load_instruments)
    12613    0.028    0.000    0.078    0.000 midifiles.py:269(_read_message)
    25229    0.028    0.000    0.059    0.000 messages.py:371(__setattr__)
    12613    0.023    0.000    0.036    0.000 messages.py:433(build_message)
    26098    0.014    0.000    0.024    0.000 messages.py:135(check_time)
        1    0.011    0.011    0.269    0.269 pretty_midi.py:43(__init__)
    25226    0.011    0.000    0.011    0.000 {method 'update' of 'dict' objects}
    26975    0.011    0.000    0.011    0.000 midifiles.py:56(read_byte)
    13056    0.010    0.000    0.012    0.000 midifiles.py:88(read_list)
    53142    0.010    0.000    0.010    0.000 {isinstance}
    13485    0.009    0.000    0.015    0.000 midifiles.py:260(_read_variable_int)
    25228    0.007    0.000    0.007    0.000 {method 'format' of 'str' objects}
     7645    0.005    0.000    0.005    0.000 pretty_midi.py:241(__get_instrument)
        1    0.005    0.005    0.005    0.005 pretty_midi.py:149(_load_metadata)
        1    0.003    0.003    0.003    0.003 pretty_midi.py:114(_load_tempo_changes)
    13049    0.003    0.000    0.003    0.000 midifiles.py:65(peek_byte)
        1    0.003    0.003    0.272    0.272 <string>:1(<module>)
    12613    0.003    0.000    0.003    0.000 messages.py:124(get_spec)

python-midi

         314691 function calls in 0.220 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    13050    0.053    0.000    0.124    0.000 fileio.py:57(parse_midi_event)
        1    0.036    0.036    0.054    0.054 pretty_midi.py:213(_load_instruments)
    13049    0.025    0.000    0.031    0.000 events.py:34(__init__)
    12614    0.016    0.000    0.046    0.000 events.py:67(__init__)
    52223    0.010    0.000    0.010    0.000 {isinstance}
    13485    0.010    0.000    0.011    0.000 util.py:2(read_varlen)
        1    0.010    0.010    0.135    0.135 fileio.py:46(parse_track)
        1    0.009    0.009    0.016    0.016 pretty_midi.py:144(_load_metadata)
    39147    0.006    0.000    0.006    0.000 {setattr}
     7645    0.005    0.000    0.005    0.000 pretty_midi.py:236(__get_instrument)
    13049    0.004    0.000    0.004    0.000 {range}
    53592    0.004    0.000    0.004    0.000 {ord}
    24780    0.004    0.000    0.004    0.000 events.py:117(get_pitch)
        1    0.003    0.003    0.007    0.007 pretty_midi.py:109(_load_tempo_changes)
        1    0.003    0.003    0.220    0.220 <string>:1(<module>)
    25952    0.003    0.000    0.003    0.000 {method 'append' of 'list' objects}
     4956    0.003    0.000    0.003    0.000 containers.py:24(__init__)
        1    0.003    0.003    0.003    0.003 containers.py:42(make_ticks_abs)
    12614    0.002    0.000    0.002    0.000 events.py:215(is_event)
    13049    0.002    0.000    0.002    0.000 events.py:102(is_event)
     9912    0.002    0.000    0.002    0.000 events.py:123(get_velocity)
@craffel
Copy link
Owner Author

craffel commented Oct 4, 2016

This likely could be helped by some optimizations to mido; beyond that, it would be great to switch to a native C++ backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant