hendriknielaender/zBench

Revise benchmark setup api

Closed this issue · 1 comments

Issue Description

The current process for setting up and executing benchmarks may present confusion for new users. It's unclear why initialization of results and the benchmark needs to be done separately, and similarly, the rationale behind de-initializing results but not the benchmark or allocator is not evident.

This complexity could hinder new user engagement and overall usability of the benchmarking tool. Streamlining the API would significantly improve the user experience, making it more intuitive and straightforward.

Suggested Improvement

A revision to the API is proposed to encapsulate the benchmark setup and execution in a more user-friendly and intuitive manner. The following code snippet illustrates the proposed streamlined approach:

var bench = Benchmark.init(std.heap.page_allocator, .{
    .iterations = 10,
});
defer bench.deinit();
try bench.add("basic example", basicfn);
try bench.add("sleep example", sleepfn);
try bench.run();

This suggested approach aims to enhance the benchmarking process by:

  • Simplifying the de-initialization process for ease of use.
  • Facilitating the addition and execution of benchmarks in a more intuitive manner.