MurrellGroup / MolecularEvolution.jl

A Julia framework for developing phylogenetic models
MIT License
9 stars 4 forks source link

Replace deepcopy #18

Closed nossleinad closed 2 months ago

nossleinad commented 2 months ago

Follow up to PR #16

This PR accomplishes two things:

  1. Replaces deepcopy with copy_partition and copy_message throughout the whole package
  2. Implements copy_partition for SWMPartition

Example where we have replaced deepcopy:

tree = sim_tree(n = 100_000)
empty_message = [NucleotidePartition(30)]
@time MolecularEvolution.random_leaf_init!(tree, empty_message)

# main
 0.521992 seconds (6.95 M allocations: 379.846 MiB, 24.52% gc time, 9.05% compilation time)

# PR
 0.405800 seconds (6.73 M allocations: 346.599 MiB, 28.74% gc time, 11.90% compilation time)

Example with SWMPartition:

tree = sim_tree(n = 10_000)
@time internal_message_init!(tree, SWMPartition{CodonPartition}(CodonPartition(30), 2))

# main
 0.536884 seconds (800.27 k allocations: 1.737 GiB, 29.93% gc time, 1.52% compilation time)

# PR
 0.355919 seconds (679.98 k allocations: 1.718 GiB, 46.63% gc time)