system/ramspeed:Add automated testing process
In the previous ramspeed test process, it was necessary to keep adding size to achieve speed tests for different sizes of memcpy and memset. After the modification, the results will be automatically looped from 32k to the input size.
This commit is contained in:
parent
d03b87b1bc
commit
902ae591b1
@ -138,6 +138,11 @@ static void parse_commandline(int argc, FAR char **argv,
|
||||
break;
|
||||
case 's':
|
||||
OPTARG_TO_VALUE(info->size, size_t, 10);
|
||||
if (info->size < 32)
|
||||
{
|
||||
printf(RAMSPEED_PREFIX "<size> must >= 32");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'v':
|
||||
OPTARG_TO_VALUE(info->value, uint8_t, 16);
|
||||
@ -360,9 +365,25 @@ static void memcpy_speed_test(FAR void *dest, FAR const void *src,
|
||||
uint32_t cost_time_system;
|
||||
uint32_t cost_time_internal;
|
||||
uint32_t cnt;
|
||||
const size_t total_size = size * repeat_cnt;
|
||||
uint32_t step;
|
||||
size_t total_size;
|
||||
irqstate_t flags;
|
||||
|
||||
printf("______memcpy performance______\n");
|
||||
|
||||
for (step = 32; step <= size; step <<= 1)
|
||||
{
|
||||
total_size = step * repeat_cnt;
|
||||
|
||||
if (step < 1024)
|
||||
{
|
||||
printf("______do %" PRIu32 " B operation______\n", step);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("______do %" PRIu32 " KB operation______\n", step / 1024);
|
||||
}
|
||||
|
||||
if (irq_disable)
|
||||
{
|
||||
flags = enter_critical_section();
|
||||
@ -372,7 +393,7 @@ static void memcpy_speed_test(FAR void *dest, FAR const void *src,
|
||||
|
||||
for (cnt = 0; cnt < repeat_cnt; cnt++)
|
||||
{
|
||||
memcpy(dest, src, size);
|
||||
memcpy(dest, src, step);
|
||||
}
|
||||
|
||||
cost_time_system = get_time_elaps(start_time);
|
||||
@ -381,7 +402,7 @@ static void memcpy_speed_test(FAR void *dest, FAR const void *src,
|
||||
|
||||
for (cnt = 0; cnt < repeat_cnt; cnt++)
|
||||
{
|
||||
internal_memcpy(dest, src, size);
|
||||
internal_memcpy(dest, src, step);
|
||||
}
|
||||
|
||||
cost_time_internal = get_time_elaps(start_time);
|
||||
@ -394,6 +415,7 @@ static void memcpy_speed_test(FAR void *dest, FAR const void *src,
|
||||
print_rate("system memcpy():\t", total_size, cost_time_system);
|
||||
print_rate("internal memcpy():\t", total_size, cost_time_internal);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: memset_speed_test
|
||||
@ -407,9 +429,25 @@ static void memset_speed_test(FAR void *dest, uint8_t value,
|
||||
uint32_t cost_time_system;
|
||||
uint32_t cost_time_internal;
|
||||
uint32_t cnt;
|
||||
const size_t total_size = size * repeat_num;
|
||||
uint32_t step;
|
||||
size_t total_size;
|
||||
irqstate_t flags;
|
||||
|
||||
printf("______memset performance______\n");
|
||||
|
||||
for (step = 32; step <= size; step <<= 1)
|
||||
{
|
||||
total_size = step * repeat_num;
|
||||
|
||||
if (step < 1024)
|
||||
{
|
||||
printf("______do %" PRIu32 " B operation______\n", step);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("______do %" PRIu32 " KB operation______\n", step / 1024);
|
||||
}
|
||||
|
||||
if (irq_disable)
|
||||
{
|
||||
flags = enter_critical_section();
|
||||
@ -419,7 +457,7 @@ static void memset_speed_test(FAR void *dest, uint8_t value,
|
||||
|
||||
for (cnt = 0; cnt < repeat_num; cnt++)
|
||||
{
|
||||
memset(dest, value, size);
|
||||
memset(dest, value, step);
|
||||
}
|
||||
|
||||
cost_time_system = get_time_elaps(start_time);
|
||||
@ -428,7 +466,7 @@ static void memset_speed_test(FAR void *dest, uint8_t value,
|
||||
|
||||
for (cnt = 0; cnt < repeat_num; cnt++)
|
||||
{
|
||||
internal_memset(dest, value, size);
|
||||
internal_memset(dest, value, step);
|
||||
}
|
||||
|
||||
cost_time_internal = get_time_elaps(start_time);
|
||||
@ -441,6 +479,7 @@ static void memset_speed_test(FAR void *dest, uint8_t value,
|
||||
print_rate("system memset():\t", total_size, cost_time_system);
|
||||
print_rate("internal memset():\t", total_size, cost_time_internal);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
Loading…
Reference in New Issue
Block a user