File: belle_sip_fast_uri_tester.c

package info (click to toggle)
belle-sip 5.1.64%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,036 kB
  • sloc: ansic: 275,494; cpp: 2,766; cs: 418; makefile: 184; python: 86; xml: 47; sh: 41; objc: 38; ruby: 8
file content (63 lines) | stat: -rw-r--r-- 2,275 bytes parent folder | download
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

/*
 * Copyright (c) 2012-2019 Belledonne Communications SARL.
 *
 * This file is part of belle-sip.
 *
 * This program 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.
 *
 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "belle-sip/belle-sip.h"
#include "belle_sip_tester.h"
#include "belle_sip_internal.h"

#include <inttypes.h>

#define belle_sip_uri_parse belle_sip_fast_uri_parse

/*test body*/
#include "belle_sip_base_uri_tester.c"

#undef belle_sip_uri_parse

static void perf(void) {
	uint64_t t1, t2, start=bctbx_get_cur_time_ms();
	int i=0;
	for (i=0;i<1000;i++) {
		belle_sip_uri_t * uri = belle_sip_uri_parse("sip:+331231231231@sip.exmaple.org;user=phone");
		belle_sip_object_unref(uri);
	}

	t1 = bctbx_get_cur_time_ms() - start;
	start=bctbx_get_cur_time_ms();
	belle_sip_message("t1 = %" PRIu64 "",t1);

	for (i=0;i<1000;i++) {
		belle_sip_uri_t * uri = belle_sip_fast_uri_parse("sip:+331231231231@sip.exmaple.org;user=phone");
		belle_sip_object_unref(uri);
	}
	t2 = bctbx_get_cur_time_ms() - start;
	belle_sip_message("t2 = %" PRIu64 "",t2);
#ifdef __APPLE__ /*antlr3.4 seems much more sensitive to belle_sip_fast_uri_parse optimisation than 3.2, so reserving this test to apple platform where antlr3.2 is unlikely to be found*/
	BC_ASSERT_GREATER(((float)(t1-t2))/(float)(t1), 0.4, float, "%f");
#endif
}
static test_t tests[] ={TEST_NO_TAG("perf", perf)};


test_suite_t fast_sip_uri_test_suite = {"FAST SIP URI", NULL, NULL, belle_sip_tester_before_each, belle_sip_tester_after_each,
	sizeof(uri_tests) / sizeof(uri_tests[0]), uri_tests};

test_suite_t perf_sip_uri_test_suite = {"FAST SIP URI 2", NULL, NULL, belle_sip_tester_before_each, belle_sip_tester_after_each,
	sizeof(tests) / sizeof(tests[0]), tests};