I have a score function to evaluate a local search algorithm whose results vary between seeds. The algorithm is anytime and its runtime is fixed. Even though the Criterion framework generalizes over impl Measurement, I couldn't find a way for it to measure using the score function instead. I'd like to know if it is possible to implement this with Criterion?
I cannot implement the API for Measurement, from https://docs.rs/criterion/latest/criterion/measurement/trait.Measurement.html. Precisely, start(&self) and end(&self, i) does not depend on the output of the algorithm.
MarcoXerox, that is correct. Criterion is not really designed for what you are attempting to do (I think it may make some assumptions that the measurement is proportional to the time of execution). However, I think this should be fairly easy to achieve with
iter_customsince it lets you provide the measurement instead of callingstartandend. First define a placeholder measurement for your score type.Then just return the value manually as part of
iter_custominstead of letting criterion perform the measurement. Just make sure you properly account for the number of iterations being requested.I believe this should work for your problem.