Changeset e7f9a09 in mainline for uspace/app/hbench/hbench.h


Ignore:
Timestamp:
2019-01-21T13:20:31Z (5 years ago)
Author:
Vojtech Horky <vojtech.horky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d17cf8c
Parents:
94ebebf
Message:

hbench: less parameters to benchmark runners

Merge stopwatch as well as error message buffer into one structure to
simplify benchmark runner signature.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/hbench/hbench.h

    r94ebebf re7f9a09  
    3838
    3939#include <errno.h>
     40#include <stdarg.h>
    4041#include <stdbool.h>
     42#include <stdio.h>
    4143#include <perf.h>
    4244
    43 /** Simple wrapper around system stopwatch.
     45/** Single run information.
     46 *
     47 * Used to store both performance information (now, only wall-clock
     48 * time) as well as information about error.
     49 *
     50 * Use proper access functions when modifying data inside this structure.
    4451 *
    4552 * Eventually, we could collection of hardware counters etc. without
     
    4855typedef struct {
    4956        stopwatch_t stopwatch;
    50 } benchmeter_t;
     57        char *error_buffer;
     58        size_t error_buffer_size;
     59} bench_run_t;
    5160
    52 static inline void benchmeter_init(benchmeter_t *meter)
     61static inline void bench_run_init(bench_run_t *run, char *error_buffer,
     62    size_t error_buffer_size)
    5363{
    54         stopwatch_init(&meter->stopwatch);
     64        stopwatch_init(&run->stopwatch);
     65        run->error_buffer = error_buffer;
     66        run->error_buffer_size = error_buffer_size;
    5567}
    5668
    57 static inline void benchmeter_start(benchmeter_t *meter)
     69static inline void bench_run_start(bench_run_t *run)
    5870{
    59         stopwatch_start(&meter->stopwatch);
     71        stopwatch_start(&run->stopwatch);
    6072}
    6173
    62 static inline void benchmeter_stop(benchmeter_t *meter)
     74static inline void bench_run_stop(bench_run_t *run)
    6375{
    64         stopwatch_stop(&meter->stopwatch);
     76        stopwatch_stop(&run->stopwatch);
    6577}
    6678
    67 typedef bool (*benchmark_entry_t)(benchmeter_t *, uint64_t,
    68     char *, size_t);
    69 typedef bool (*benchmark_helper_t)(char *, size_t);
     79static inline bool bench_run_fail(bench_run_t *run, const char *fmt, ...)
     80{
     81        va_list args;
     82        va_start(args, fmt);
     83        vsnprintf(run->error_buffer, run->error_buffer_size, fmt, args);
     84        va_end(args);
     85
     86        return false;
     87}
     88
     89typedef bool (*benchmark_entry_t)(bench_run_t *, uint64_t);
     90typedef bool (*benchmark_helper_t)(bench_run_t *);
    7091
    7192typedef struct {
     
    81102
    82103extern errno_t csv_report_open(const char *);
    83 extern void csv_report_add_entry(benchmeter_t *, int, benchmark_t *, uint64_t);
     104extern void csv_report_add_entry(bench_run_t *, int, benchmark_t *, uint64_t);
    84105extern void csv_report_close(void);
    85106
Note: See TracChangeset for help on using the changeset viewer.