同是fstream,为什么性能差这么多?
我用vc++写了两个程序,
一个
#include "stdafx.h"
#include "fstream.h"
int main(int argc, char* argv[])
{
ifstream fin("fj9.apr");
ofstream fout("temp");
fout<<fin.rdbuf();
fin.close();
fin.close();
return 0;
}
另一个
#include "stdafx.h"
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
ifstream fin("fj9.apr");
ofstream fout("temp");
fout<<fin.rdbuf();
fin.close();
fin.close();
return 0;
}
那个fj9.apr一共3M。第一个执行只用了1秒不到,第二个用了差不多8秒,同是fstream,性能怎么差这么多?