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

Coulomb collections #530

Open
wants to merge 9 commits into
base: scala3
Choose a base branch
from
Open

Coulomb collections #530

wants to merge 9 commits into from

Conversation

erikerlandson
Copy link
Owner

An attempt to implement #50

@erikerlandson
Copy link
Owner Author

As an efficiency measure I tried creating a subclass of scala.Conversion that can also operate directly on "raw" values inside a QuantityVector. Doing this will break ABI compatibility, and so I wanted to verify whether it actually improves efficiency before I commit to it.

I benchmarked this using a couple of test functions:

def bench1[V, U](qv: QuantityVector[V, U])(using cnv: scala.Conversion[Quantity[V, U], Quantity[Double, Meter]]): QuantityVector[Double, Meter] =
    qv.map(cnv)

def bench2[V, U](qv: QuantityVector[V, U])(using cnv: QuantityConversion[V, U, Double, Meter]): QuantityVector[Double, Meter] =
    QuantityVector[Meter](qv.values.map(cnv.raw))

The bench2 variation that uses the raw conversion is > 7x faster. Furthermore, it produces significantly less load on the garbage collection, so the benefits are even bigger.

This demonstrates the benefits of breaking MIMA with QuantityConversion, and also justifies the benefits of defining QuantityVector in the first place.

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.

1 participant