Skip to content

Benchmarking memory footprint of data structures. #49

@tiuno

Description

@tiuno

There's a measure that I want to do and I haven't managed to achieve this using Bechamel. The end goal is to measure the memory footprint of values using Obj.reachable_words.

Suppose that we want to compare the memory footprint of different implementations of semi-persisent lists.

Let's consider that we have a module type SP_LIST and different implementations: module A : SP_LIST and module B : SP_LIST.

Then we have a generic test signature with a make_list function that will allocate a value, let's call it v, that will be passed to the function bench, which will be the basis of the test. I would like to compare the foot print of v before and after the call of bench.

module type TEST = functor (Impl : SP_LIST) -> sig
  type t

  val make_list : unit -> t
  val bench : int -> t -> unit
end

My idea was to try to make a test with resources for modules A and B and then, use the alloc and free functions to register the values of interest in a table that is read by the measurement module and use Ob.reachable_words.

However, this doesn't work. When the test is set up with multiple allocations the alloc and free functions are called exactly once for each run of n executions of bench. So the measured values keep decreasing as n grows. This is because the footprint of execution n doesn't add up to the execution n+1 of bench.

I would like to make a feature request, that I'm willing to implement, to add such measurement features. Although I don't know which design would fit properly with Bechamel's mindset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions