问题描述
我有一个应用程序可以读取大型二进制文件,一切正常,但作为管理员运行比通过我的普通帐户运行要快得多。有人可以帮我理解为什么吗?
下面的示例应用程序展示了这个问题。一些细节: 视窗 10.0.19041 C++11 内置于 Visual Studio 2019(作为 x64)。 独立的机器,没有域,只是一个具有管理员权限的普通用户帐户,以及 测试文件是本地的。
#include <chrono>
#include <fstream>
#include <iostream>
int main()
{
auto aFile = R"(SomeLargeBinaryFile)";
std::ifstream fileStream(aFile,std::ios::binary);
typedef std::chrono::high_resolution_clock TheClock;
auto startTime = TheClock::Now();
int offset = (int)2e8;
fileStream.seekg(offset);
int bucketSize = (int)3.75e8;
double* bucket = new double[bucketSize]();
fileStream.read(reinterpret_cast<char*>(bucket),sizeof(double) * bucketSize);
auto endTime = TheClock::Now();
auto elapsed = endTime - startTime;
auto elapsedMS = std::chrono::duration_cast<std::chrono::milliseconds>(elapsed);
auto elapsedSec = elapsedMS.count() / 1000.0;
std::cout << " Sample reader elapsed seconds: " << elapsedSec << std::endl;
fileStream.close();
delete[] bucket;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)