Skip to content

Compare performance between data types used for Price #10

@minicheddar

Description

@minicheddar

Rust does not allow ordering of f32/f64s as part of std. This prevents using f64 as a key in BTreeMap<f64, OrderbookLevel>.

For now, we should just use this (https://crates.io/crates/ordered-float), but I'm curious on the performance difference between.

  • Implementing PartialOrd for floats as above
  • Having serde deserialise 'float-like' data straight to Decimal
  • Having serde deserialise to f64, but converting to Decimal when returning MarketDataKind:L2Update/Snapshot
  • Storing prices as u64 with a mantissa on the number of floating points as a separate piece of metadata (like smart contracts)

This is definitely a low-priority premature micro-optimisation!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions