aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/vector/test/ip_csum.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-12-02 11:28:57 +0100
committerOle Tr�an <otroan@employees.org>2021-12-02 16:19:17 +0000
commit3323e2018d6d736a25b15902bc85f559ea98adb5 (patch)
treea00515198ef534c14c1df1fb5dc69c2cc8e55929 /src/vppinfra/vector/test/ip_csum.c
parente893beab2713a7fa1b8d5e9567b7c004e625fec6 (diff)
vppinfra: add perf testing to test_vector_func
Type: improvement Change-Id: I7aacd58d113c13036c15655817400032dd8d1932 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/vector/test/ip_csum.c')
-rw-r--r--src/vppinfra/vector/test/ip_csum.c65
1 files changed, 63 insertions, 2 deletions
diff --git a/src/vppinfra/vector/test/ip_csum.c b/src/vppinfra/vector/test/ip_csum.c
index 135d5ae63b2..cb33c036120 100644
--- a/src/vppinfra/vector/test/ip_csum.c
+++ b/src/vppinfra/vector/test/ip_csum.c
@@ -80,7 +80,7 @@ static clib_error_t *
test_clib_ip_csum (clib_error_t *err)
{
u8 *buf;
- buf = clib_mem_alloc_aligned (65536, CLIB_CACHE_LINE_BYTES);
+ buf = test_mem_alloc (65536);
for (int i = 0; i < 65536; i++)
buf[i] = 0xf0 + ((i * 7) & 0xf);
@@ -110,11 +110,72 @@ test_clib_ip_csum (clib_error_t *err)
}
}
done:
- clib_mem_free (buf);
+ test_mem_free (buf);
return err;
}
+void __test_perf_fn
+perftest_ip4_hdr (int fd, test_perf_t *tp)
+{
+ u32 n = tp->n_ops;
+ u8 *data = test_mem_alloc_and_splat (20, n, (void *) &test1);
+ u16 *res = test_mem_alloc (n * sizeof (u16));
+
+ test_perf_event_enable (fd);
+ for (int i = 0; i < n; i++)
+ res[i] = clib_ip_csum (data + i * 20, 20);
+ test_perf_event_disable (fd);
+
+ test_mem_free (data);
+ test_mem_free (res);
+}
+
+void __test_perf_fn
+perftest_tcp_payload (int fd, test_perf_t *tp)
+{
+ u32 n = tp->n_ops;
+ volatile uword *lenp = &tp->arg0;
+ u8 *data = test_mem_alloc_and_splat (20, n, (void *) &test1);
+ u16 *res = test_mem_alloc (n * sizeof (u16));
+
+ test_perf_event_enable (fd);
+ for (int i = 0; i < n; i++)
+ res[i] = clib_ip_csum (data + i * lenp[0], lenp[0]);
+ test_perf_event_disable (fd);
+
+ test_mem_free (data);
+ test_mem_free (res);
+}
+
+void __test_perf_fn
+perftest_byte (int fd, test_perf_t *tp)
+{
+ volatile uword *np = &tp->n_ops;
+ u8 *data = test_mem_alloc_and_fill_inc_u8 (*np, 0, 0);
+ u16 *res = test_mem_alloc (sizeof (u16));
+
+ test_perf_event_enable (fd);
+ res[0] = clib_ip_csum (data, np[0]);
+ test_perf_event_disable (fd);
+
+ test_mem_free (data);
+ test_mem_free (res);
+}
+
REGISTER_TEST (clib_ip_csum) = {
.name = "clib_ip_csum",
.fn = test_clib_ip_csum,
+ .perf_tests = PERF_TESTS (
+ { .name = "ip4_hdr",
+ .op_name = "IP4Hdr",
+ .n_ops = 1024,
+ .fn = perftest_ip4_hdr },
+ { .name = "tcp_paylaad",
+ .op_name = "1460Byte",
+ .n_ops = 16,
+ .arg0 = 1460,
+ .fn = perftest_tcp_payload },
+ { .name = "byte", .op_name = "Byte", .n_ops = 16384, .fn = perftest_byte }
+
+ ),
};