-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathdebug.c
More file actions
57 lines (46 loc) · 1.09 KB
/
debug.c
File metadata and controls
57 lines (46 loc) · 1.09 KB
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
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include<time.h>
void printHex(unsigned char *name, unsigned char *c, int n)
{
int i;
#define _print printf
_print ("\n---------------------[%s ,len = %d, start ]----------------------\n",name,n);
for (i = 0; i < n; i++) {
_print("0x%02X, ", c[i]);
if ((i%4) == 3)
_print(" ");
if ((i%16) == 15)
_print("\n");
}
if ((i%16) != 0)
_print("\n");
_print("----------------------[%s end ]----------------------\n",name);
}
void speed_test( char *name, int len)
{
static volatile unsigned long long byte = 0;
static volatile unsigned long long count = 0;
static time_t t1, t2;
static int flag = 0;
if (!flag) {
flag = 3;
time(&t1);
}
byte += len;
count++;
time(&t2);
if ((t2-t1) >= flag) {
unsigned long long byte_temp = byte;
unsigned long long count_temp = count;
if (byte_temp)
byte_temp = byte_temp*8/flag/1024/1024;
if (count_temp)
count_temp = count_temp/flag;
printf(" %s speed = %lld Mb, %lld Hz \n", name, byte_temp, count_temp);
t1 = t2;
byte = 0;
count = 0;
}
}