From 74bb72946222f6465f05d5980c491ee88ab2dc5a Mon Sep 17 00:00:00 2001 From: wuyangyong Date: Sun, 2 Jan 2011 16:39:23 +0000 Subject: [PATCH] fix speed calculate bug git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1231 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- examples/file/readspeed.c | 2 +- examples/file/writespeed.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/file/readspeed.c b/examples/file/readspeed.c index 2426756fab..a41c126550 100644 --- a/examples/file/readspeed.c +++ b/examples/file/readspeed.c @@ -55,7 +55,7 @@ void readspeed(const char* filename, int block_size) rt_free(buff_ptr); /* calculate read speed */ - rt_kprintf("File read speed: %d byte/s\n", total_length/ (tick/RT_TICK_PER_SECOND)); + rt_kprintf("File read speed: %d byte/s\n", total_length*RT_TICK_PER_SECOND/tick); } #ifdef RT_USING_FINSH diff --git a/examples/file/writespeed.c b/examples/file/writespeed.c index 22b6d565d2..157b24f47a 100644 --- a/examples/file/writespeed.c +++ b/examples/file/writespeed.c @@ -20,7 +20,7 @@ void writespeed(const char* filename, int total_length, int block_size) char *buff_ptr; rt_tick_t tick; - fd = open(filename, O_WRONLY | O_WRONLY | O_TRUNC, 0); + fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0); if (fd < 0) { rt_kprintf("open file:%s failed\n", filename); @@ -53,7 +53,7 @@ void writespeed(const char* filename, int total_length, int block_size) rt_kprintf("write failed\n"); break; } - + index ++; } tick = rt_tick_get() - tick; @@ -63,7 +63,7 @@ void writespeed(const char* filename, int total_length, int block_size) rt_free(buff_ptr); /* 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*RT_TICK_PER_SECOND/tick); } #ifdef RT_USING_FINSH