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

Optimize unsafe_sample #787

Merged
merged 1 commit into from
Aug 24, 2023
Merged

Conversation

eendebakpt
Copy link
Contributor

In unsafe_sample the sample_times is guaranteed to be a numpy array. Calling searchsorted from the array is more efficient.

For a small numpy array:

In [66]: %timeit sample_times.searchsorted( (0,0), 'left')
1.53 µs ± 63.9 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

In [67]: %timeit np.searchsorted(sample_times, (0,0), 'left')
2.73 µs ± 424 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

@terrorfisch

@github-actions
Copy link

Test Results

       6 files         6 suites   6m 50s ⏱️
1 216 tests 1 161 ✔️   55 💤 0
7 296 runs  6 966 ✔️ 330 💤 0

Results for commit 58a3471.

@terrorfisch
Copy link
Member

Thanks. Seems like numpy's array_function_dispatch introduces quite some overhead.

@terrorfisch terrorfisch merged commit e36e4cc into qutech:master Aug 24, 2023
9 checks passed
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