parent
3ff0c07b38
commit
b0591443e3
|
@ -32,31 +32,31 @@ void writespeed(const char* filename, int total_length, int block_size)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prepare write data */
|
/* prepare write data */
|
||||||
for (index = 0; index < block_size; index++)
|
for (index = 0; index < block_size; index++)
|
||||||
{
|
{
|
||||||
buff_ptr[index] = index;
|
buff_ptr[index] = index;
|
||||||
}
|
}
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
/* get the beginning tick */
|
/* get the beginning tick */
|
||||||
tick = rt_tick_get();
|
tick = rt_tick_get();
|
||||||
while (index < total_length / block_size)
|
while (index < total_length / block_size)
|
||||||
{
|
{
|
||||||
length = write(fd, buff_ptr, block_size);
|
length = write(fd, buff_ptr, block_size);
|
||||||
if (length != block_size)
|
if (length != block_size)
|
||||||
{
|
{
|
||||||
rt_kprintf("write failed\n");
|
rt_kprintf("write failed\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
index ++;
|
index ++;
|
||||||
}
|
}
|
||||||
tick = rt_tick_get() - tick;
|
tick = rt_tick_get() - tick;
|
||||||
|
|
||||||
/* close file and release memory */
|
/* close file and release memory */
|
||||||
close(fd);
|
close(fd);
|
||||||
rt_free(buff_ptr);
|
rt_free(buff_ptr);
|
||||||
|
|
||||||
/* calculate write speed */
|
/* calculate write speed */
|
||||||
rt_kprintf("File write speed: %d byte/s\n", total_length / tick * RT_TICK_PER_SECOND);
|
rt_kprintf("File write speed: %d byte/s\n", total_length / tick * RT_TICK_PER_SECOND);
|
||||||
|
|
Loading…
Reference in New Issue