Changeset e7f9a09 in mainline for uspace/app/hbench/hbench.h
- Timestamp:
- 2019-01-21T13:20:31Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d17cf8c
- Parents:
- 94ebebf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hbench/hbench.h
r94ebebf re7f9a09 38 38 39 39 #include <errno.h> 40 #include <stdarg.h> 40 41 #include <stdbool.h> 42 #include <stdio.h> 41 43 #include <perf.h> 42 44 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. 44 51 * 45 52 * Eventually, we could collection of hardware counters etc. without … … 48 55 typedef struct { 49 56 stopwatch_t stopwatch; 50 } benchmeter_t; 57 char *error_buffer; 58 size_t error_buffer_size; 59 } bench_run_t; 51 60 52 static inline void benchmeter_init(benchmeter_t *meter) 61 static inline void bench_run_init(bench_run_t *run, char *error_buffer, 62 size_t error_buffer_size) 53 63 { 54 stopwatch_init(&meter->stopwatch); 64 stopwatch_init(&run->stopwatch); 65 run->error_buffer = error_buffer; 66 run->error_buffer_size = error_buffer_size; 55 67 } 56 68 57 static inline void bench meter_start(benchmeter_t *meter)69 static inline void bench_run_start(bench_run_t *run) 58 70 { 59 stopwatch_start(& meter->stopwatch);71 stopwatch_start(&run->stopwatch); 60 72 } 61 73 62 static inline void bench meter_stop(benchmeter_t *meter)74 static inline void bench_run_stop(bench_run_t *run) 63 75 { 64 stopwatch_stop(& meter->stopwatch);76 stopwatch_stop(&run->stopwatch); 65 77 } 66 78 67 typedef bool (*benchmark_entry_t)(benchmeter_t *, uint64_t, 68 char *, size_t); 69 typedef bool (*benchmark_helper_t)(char *, size_t); 79 static 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 89 typedef bool (*benchmark_entry_t)(bench_run_t *, uint64_t); 90 typedef bool (*benchmark_helper_t)(bench_run_t *); 70 91 71 92 typedef struct { … … 81 102 82 103 extern errno_t csv_report_open(const char *); 83 extern void csv_report_add_entry(bench meter_t *, int, benchmark_t *, uint64_t);104 extern void csv_report_add_entry(bench_run_t *, int, benchmark_t *, uint64_t); 84 105 extern void csv_report_close(void); 85 106
Note:
See TracChangeset
for help on using the changeset viewer.