读写1M或者1K所花时间测试,测试文件默认放在/sdcard/sd.test(由于sdcard目录是fuse产生的,性能会收到影响,见下一篇文章 [RK3288][Android6.0] Fuse将被SDCardFS替换 ,所以建议换个目录)
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/uio.h>
#include <dirent.h>
#include <ctype.h>
#include <sys/time.h>
#include<time.h>
#include<unistd.h>
#define Test_file "/sdcard/sd.test"
time_t now_time;
struct tm *ptr;
unsigned int write_total = 0,read_total = 0;
FILE *write_fp;
FILE *read_fp;
static inline int current_time()
{
time(&now_time);
ptr=localtime(&now_time);
printf ("[*Time