add calculate_speed_print for device_test

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1747 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
wuyangyong 2011-10-09 16:14:45 +00:00
parent b2f9217686
commit 7af3914228
1 changed files with 327 additions and 301 deletions

View File

@ -14,6 +14,30 @@
#include <rtthread.h> #include <rtthread.h>
/* calculate speed */
static void calculate_speed_print(rt_uint32_t speed)
{
rt_uint32_t k,m;
k = speed/1024UL;
if( k )
{
m = k/1024UL;
if( m )
{
rt_kprintf("%d.%dMbyte/s",m,k%1024UL*100/1024UL);
}
else
{
rt_kprintf("%d.%dKbyte/s",k,speed%1024UL*100/1024UL);
}
}
else
{
rt_kprintf("%dbyte/s",speed);
}
}
static rt_err_t _block_device_test(rt_device_t device) static rt_err_t _block_device_test(rt_device_t device)
{ {
rt_err_t result; rt_err_t result;
@ -219,7 +243,8 @@ static rt_err_t _block_device_test(rt_device_t device)
} }
tick_end = rt_tick_get(); tick_end = rt_tick_get();
rt_kprintf("read 200 sector from %d to %d, ",tick_start,tick_end); rt_kprintf("read 200 sector from %d to %d, ",tick_start,tick_end);
rt_kprintf("%d byte/s\r\n",(geometry.bytes_per_sector*200UL*RT_TICK_PER_SECOND)/(tick_end-tick_start) ); calculate_speed_print( (geometry.bytes_per_sector*200UL*RT_TICK_PER_SECOND)/(tick_end-tick_start) );
rt_kprintf("\r\n");
// sign sector write // sign sector write
tick_start = rt_tick_get(); tick_start = rt_tick_get();
@ -229,7 +254,8 @@ static rt_err_t _block_device_test(rt_device_t device)
} }
tick_end = rt_tick_get(); tick_end = rt_tick_get();
rt_kprintf("write 200 sector from %d to %d, ",tick_start,tick_end); rt_kprintf("write 200 sector from %d to %d, ",tick_start,tick_end);
rt_kprintf("%d byte/s\r\n",(geometry.bytes_per_sector*200UL*RT_TICK_PER_SECOND)/(tick_end-tick_start) ); calculate_speed_print( (geometry.bytes_per_sector*200UL*RT_TICK_PER_SECOND)/(tick_end-tick_start) );
rt_kprintf("\r\n");
} }
}// step 4: speed test }// step 4: speed test