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

Code optimisation: ensure output are actually stored as integers #136

Open
jamesmbaazam opened this issue Dec 13, 2023 · 0 comments
Open

Comments

@jamesmbaazam
Copy link
Member

As far as I can tell, the output contains only integers. You should make sure they are actually stored as integer. Not just at the end of this function but as the values are created and stored. This will be much more efficient in terms of memory and likely also computation speed.

set.seed(123)
chains <- epichains::simulate_tree(
  ntrees = 10,
  statistic = "size",
  offspring_dist = "pois",
  stat_max = 10,
  generation_time = function(n) rep(3, n),
  lambda = 2
)

lobstr::obj_size(chains)
#> 6.34 kB

lobstr::obj_size(vapply(chains, as.integer, integer(nrow(chains))))
#> 3.34 kB

Created on 2023-12-07 with reprex v2.0.2

Originally posted by @Bisaloo in #122 (comment)

@jamesmbaazam jamesmbaazam changed the title Code optimisation Code optimisation: ensure output are actually stored as integers Dec 14, 2023
@jamesmbaazam jamesmbaazam added this to the v0.2.0 milestone Jan 29, 2024
@jamesmbaazam jamesmbaazam modified the milestones: v0.2.0, v0.5.0 Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant