c++ - Large binary read in windows 10 is faster when run as admin
问题描述
I have an application that reads large binary files and all is well, but it runs much faster as admin than via my normal account. Can someone please help me understand why?
The sample application below exhibits the issue. Some specifics: Windows 10.0.19041 C++11 built in Visual Studio 2019 (as x64). Stand alone machine, no domain, just a normal user account with admin privileges, and the test file is local.
#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;
}
解决方案
推荐阅读
- python - 使用 pandas 从 zip 读取特定的 csv 文件
- java - 我想知道“Book book = (Book) obj;”的意思
- c# - ASP.NET CORE MVC 路由:尝试在 asp-all-route-data 中传递字典
- sql - 如何在 Laravel 中加入 count()?
- c# - 标签页添加表单等控件时,如何设置表单所有者
- php - PHP 代码在 MySQL 中工作,但不在 LAMP 中
- javascript - 如何将多个 i 项目带入同一个选项卡选项卡面板中
- git - 将历史调整 rebase 应用于另一个分支
- javascript - Javascript 函数的输出
- bash - (@)/[some_folder] 在那个 Shell 脚本示例的开头是什么意思?