aboutsummaryrefslogtreecommitdiff
path: root/includes/benchmark.h
blob: 3d1a2c208da037b6edde3a25e5f9a2d1d79e0c03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef __BENCHMARK_H__
#define __BENCHMARK_H__

#include "hardinfo.h"
#include "util_sysobj.h" /* for SEQ() */

#define BENCH_PTR_BITS ((unsigned int)sizeof(void*) * 8)

extern ProgramParameters params;

enum BenchmarkEntries {
    BENCHMARK_BLOWFISH_SINGLE,
    BENCHMARK_BLOWFISH_THREADS,
    BENCHMARK_BLOWFISH_CORES,
    BENCHMARK_ZLIB,
    BENCHMARK_CRYPTOHASH,
    BENCHMARK_FIB,
    BENCHMARK_NQUEENS,
    BENCHMARK_FFT,
    BENCHMARK_RAYTRACE,
    BENCHMARK_IPERF3_SINGLE,
    BENCHMARK_SBCPU_SINGLE,
    BENCHMARK_SBCPU_ALL,
    BENCHMARK_SBCPU_QUAD,
    BENCHMARK_MEMORY_SINGLE,
    BENCHMARK_MEMORY_DUAL,
    BENCHMARK_MEMORY_QUAD,
    BENCHMARK_MEMORY_ALL,
    BENCHMARK_GUI,
    BENCHMARK_N_ENTRIES
};

void benchmark_bfish_single(void);
void benchmark_bfish_threads(void);
void benchmark_bfish_cores(void);
void benchmark_memory_single(void);
void benchmark_memory_dual(void);
void benchmark_memory_quad(void);
void benchmark_memory_all(void);
void benchmark_sbcpu_single(void);
void benchmark_sbcpu_all(void);
void benchmark_sbcpu_quad(void);
void benchmark_cryptohash(void);
void benchmark_fft(void);
void benchmark_fib(void);
void benchmark_fish(void);
void benchmark_gui(void);
void benchmark_nqueens(void);
void benchmark_raytrace(void);
void benchmark_zlib(void);
void benchmark_iperf3_single(void);

typedef struct {
    double result;
    double elapsed_time;
    int threads_used;
    int revision;
    char extra[256]; /* no \n, ; or | */
} bench_value;

#define EMPTY_BENCH_VALUE {-1.0f,0,0,-1,""}

char *bench_value_to_str(bench_value r);
bench_value bench_value_from_str(const char* str);

/* Note:
 *    benchmark_parallel_for(): element [start] included, but [end] is excluded.
 *    callback(): expected to processes elements [start] through [end] inclusive.
 */
bench_value benchmark_parallel_for(gint n_threads, guint start, guint end,
                               gpointer callback, gpointer callback_data);

bench_value benchmark_parallel(gint n_threads, gpointer callback, gpointer callback_data);

bench_value benchmark_crunch_for(float seconds, gint n_threads,
                               gpointer callback, gpointer callback_data);

extern bench_value bench_results[BENCHMARK_N_ENTRIES];

/* in bench_util.c */

/* guarantee a minimum size of data
 * or return null */
gchar *get_test_data(gsize min_size);
char *md5_digest_str(const char *data, unsigned int len);
#define bench_msg(msg, ...)  fprintf (stderr, "[%s] " msg "\n", __FUNCTION__, ##__VA_ARGS__)

#endif /* __BENCHMARK_H__ */