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

Check performance of copying a sim #812

Open
cliffckerr opened this issue Dec 8, 2024 · 0 comments
Open

Check performance of copying a sim #812

cliffckerr opened this issue Dec 8, 2024 · 0 comments

Comments

@cliffckerr
Copy link
Contributor

cliffckerr commented Dec 8, 2024

Do benchmarking of running vs. copying sims of different types, and see if there are shortcuts that could be done. Copying should be slower than allocating but faster than creating, e.g.:

import numpy as np
import sciris as sc

n = int(1e8)

with sc.timer('alloc'):
    z = np.zeros(n)

with sc.timer('orig'):
    r = np.random.rand(n)

with sc.timer('np-copy'):
    q = r.copy()

with sc.timer('dcp'):
    t = sc.dcp(q)

alloc: 27.7 μs
orig: 0.373 s
np-copy: 0.105 s
dcp: 0.103 s
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