aboutsummaryrefslogtreecommitdiffstats
path: root/src/benchmark.c
blob: 8896a3bc17457694e890c0090736b3d6d6f4d67c (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
/*
 * This file is part of gapk (GSM Audio Pocket Knife).
 *
 * gapk is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * gapk is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gapk.  If not, see <http://www.gnu.org/licenses/>.
 *
 * (C) 2014 Harald Welte <laforge@gnumonks.org>
 */

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>

#include <osmocom/gapk/benchmark.h>
#include <osmocom/gapk/codecs.h>

struct osmo_gapk_bench_cycles *
	osmo_gapk_bench_codec[_CODEC_MAX] = { NULL };

int osmo_gapk_bench_enable(enum osmo_gapk_codec_type codec)
{
	struct osmo_gapk_bench_cycles *bench;

	/* Allocate zero-initialized memory */
	bench = (struct osmo_gapk_bench_cycles *)
		calloc(1, sizeof(struct osmo_gapk_bench_cycles));
	if (!bench)
		return -ENOMEM;

	/* Set up pointer */
	osmo_gapk_bench_codec[codec] = bench;

	return 0;
}

void osmo_gapk_bench_free(void)
{
	int i;

	for (i = 0; i < _CODEC_MAX; i++)
		free(osmo_gapk_bench_codec[i]);
}