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

Speed up ProcessWithContext.process_*() #104

Merged
merged 3 commits into from
Mar 13, 2023
Merged

Conversation

frankenjoe
Copy link
Collaborator

Relates to #100

Speeds up PredictWithContext.process_*() by avoiding calls to pd.concat() on a lot of small pd.Series objects. Instead, we now concatenate lists and create the final pd.Series from those.

Benchmark

import time
import audb
import audinterface


db = audb.load(
    'emodb',
    version='1.3.0',
    format='wav',
    sampling_rate=16000,
    mixdown=True,
)

def process_func(x, sr, starts, ends):
    y = []
    for start, end in zip(starts, ends):
        y.append(x[:, start:end].mean())
    return y

process = audinterface.ProcessWithContext(process_func=process_func)

t = time.time()
process.process_index(db.files)
print(time.time() - t)
  • main branch: ~4.0 s
  • this branch: ~0.6 s

@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

Merging #104 (f0a77ee) into main (7ad15b7) will not change coverage.
The diff coverage is 100.0%.

Impacted Files Coverage Δ
audinterface/core/process_with_context.py 100.0% <100.0%> (ø)

... and 2 files with indirect coverage changes

@hagenw
Copy link
Member

hagenw commented Mar 13, 2023

As the main branch now incorporates #102 and #103 I re-did the benchmark and I get:

  • main branch: ~1.9 s
  • this branch: ~0.4 s

@hagenw hagenw merged commit c74dfff into main Mar 13, 2023
@hagenw hagenw deleted the speed-up-process-with-context branch March 13, 2023 11:37
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

Successfully merging this pull request may close these issues.

2 participants