1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /* 8 CRYS tester performance statistics functions 9 */ 10 11 #ifndef __TST_PERF_H__ 12 #define __TST_PERF_H__ 13 14 #include <stdint.h> 15 16 typedef enum { 17 TST_PERF_OP_NULL, 18 TST_PERF_OP_RSA_ENC_PRIM, 19 TST_PERF_OP_RSA_ENC_1_5, 20 TST_PERF_OP_RSA_ENC_2_1, 21 TST_PERF_OP_RSA_DEC_PRIM, 22 TST_PERF_OP_RSA_DEC_1_5, 23 TST_PERF_OP_RSA_DEC_2_1, 24 TST_PERF_OP_RSA_SIGN_1_5, 25 TST_PERF_OP_RSA_SIGN_2_1, 26 TST_PERF_OP_RSA_VER_1_5, 27 TST_PERF_OP_RSA_VER_2_1, 28 TST_PERF_OP_ECC_SIGN, 29 TST_PERF_OP_ECC_VER, 30 TST_PERF_OP_NUM 31 } TST_PerfOpType_t; 32 33 34 typedef struct { 35 uint32_t opCount; /* Number of operations measured */ 36 uint64_t totalVal; /* Accumulated cycles/uSec */ 37 uint64_t maxVal; /* Maximum cycles/usec */ 38 uint64_t minVal; /* Minimum cycles/usec */ 39 } PerfStats_t; 40 41 #ifdef TST_PERF 42 /* Performance data */ 43 #define TST_PERF_INIT TST_PerfStatsCycleInit 44 #define TST_PERF_START(perfData) perfData = TST_PerfStatsCycleStart() 45 #define TST_PERF_END(perfData, op) TST_PerfStatsCycleEnd(perfData, op) 46 #define TST_PERF_REPORT TST_PerfStatsCycleReport 47 #define TST_PERF_FIN TST_PerfStatsCycleFin 48 void TST_PerfStatsCycleInit(void); 49 uint64_t TST_PerfStatsCycleStart(void); 50 void TST_PerfStatsCycleEnd(uint64_t startCycles, TST_PerfOpType_t opType); 51 void TST_PerfStatsCycleReport(void); 52 void TST_PerfStatsCycleFin(void); 53 #else 54 #define TST_PERF_INIT() 55 #define TST_PERF_START(perfData) (perfData = 0) 56 #define TST_PERF_END(perfData, op) 57 #define TST_PERF_REPORT() 58 #define TST_PERF_FIN() 59 #endif 60 61 62 63 #endif /*__TST_PERF_H__*/ 64