在某些特定使用场景中可使用RAM文件系统提高系统性能,解决业务问题。一下已MPC8313作为测试平台,测试使用RAM和yaffs2文件系统时,FTP文件传输速率与应用程序加载时间的性能变化。
硬件平台:MPC8313
base版本:V1.8.0
FTP文件传输样本:bspmpc8313.elf 3.51MB
应用程序加载样本:hellofile 104.37KB
应用加载时间测试样本:test
yaffs2文件系统:
FTP文件传输耗时3.63s 平均速率:966.9KB/s
应用程序加载耗时74ms
RAM文件系统:
FTP文件传输耗时671ms 平均速率:5.23MB/s
应用程序加载耗时50ms
从测试数据可以看出,RAM会大幅度提升文件操作速率,同样的测试在DSP6678上也可得出类似结果;
测试代码:
hellofile:
#include <stdio.h>
char buf[100 * 1024] = \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" \
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
int main (int argc, char **argv)
{
printf("Hello SylixOS1!\n");
return (0);
}
test:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char **argv)
{
time_t time1, time2;
printf("Frequency:%lu\n", Lw_Time_GetFrequency());
time1 = Lw_Time_Get();
printf("%d\n", system("/root/hellofile"));
time2 = Lw_Time_Get();
printf("run time:%lu\n", (unsigned long)(time2 - time1));
return (0);
}