]> git.proxmox.com Git - ceph.git/blob - ceph/src/crypto/isa-l/isa-l_crypto/include/test.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / crypto / isa-l / isa-l_crypto / include / test.h
1 /**********************************************************************
2 Copyright(c) 2011-2016 Intel Corporation All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 **********************************************************************/
29
30
31 #ifndef _TEST_H
32 #define _TEST_H
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 // Use sys/time.h functions for time
39
40 #include <sys/time.h>
41
42 struct perf{
43 struct timeval tv;
44 };
45
46
47 inline int perf_start(struct perf *p)
48 {
49 return gettimeofday(&(p->tv), 0);
50 }
51 inline int perf_stop(struct perf *p)
52 {
53 return gettimeofday(&(p->tv), 0);
54 }
55
56 inline void perf_print(struct perf stop, struct perf start, long long dsize)
57 {
58 long long secs = stop.tv.tv_sec - start.tv.tv_sec;
59 long long usecs = secs * 1000000 + stop.tv.tv_usec - start.tv.tv_usec;
60
61 printf("runtime = %10lld usecs", usecs);
62 if (dsize != 0) {
63 #if 1 // not bug in printf for 32-bit
64 printf(", bandwidth %lld MB in %.4f sec = %.2f MB/s\n", dsize/(1024*1024),
65 ((double) usecs)/1000000, ((double) dsize) / (double)usecs);
66 #else
67 printf(", bandwidth %lld MB ", dsize/(1024*1024));
68 printf("in %.4f sec ",(double)usecs/1000000);
69 printf("= %.2f MB/s\n", (double)dsize/usecs);
70 #endif
71 }
72 else
73 printf("\n");
74 }
75
76
77 #ifdef __cplusplus
78 }
79 #endif
80
81 #endif // _TEST_H