multithreading - 将数据并行写入磁盘?

标签 multithreading image-processing c++-cli

所以我正在研究 C++/cli 图像处理库,并试图优化我的代码。基本上,我传递了图像的 System::Drawing::Bitmap,然后我需要将其写入磁盘,对其执行复杂分析并返回分析结果。我认为我可以将图像并行写入磁盘以加快速度(我的算法不会修改图像)。但是,我并没有太多地使用线程,所以我想就最好的方法来获得您的意见。

string ProcessImage(System::Drawing::Bitmap ^bmp, System::String^ targetFile)
{
    bmp->Save(targetFile);
    System::Drawing::Bitmap^ bmp8 = BitmapConvertPixelFormat(bmp, 8); //<-- a function I wrote which converts the 32bpp I am passed into an 8bpp one
    string results = Analyze(bmp8); //<--- takes a good bit of time
    return results;
}

请让我知道你的想法。
先感谢您!

最佳答案

向/从单个机械磁盘并行写入/读取不是一个好主意,因为机械磁头每次都需要旋转以服务 I/O 请求,因此使用多个线程只会不必要地反弹它并产生开销。

您可以尝试进行一些基准测试,但恐怕您只能求助于使用单个线程并按顺序编写。

关于multithreading - 将数据并行写入磁盘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10254147/

相关文章:

algorithm - 在粉末衍射图像中寻找椭圆的算法比 MultiRANSAC 更好?

iphone - slider 变化时模糊 UIImage

math - 平滑局部吊顶功能

c# - C++ CLI 中的 C# 动态关键字等效项是什么?

c++-cli - 为什么我们在单元测试时会看到 ModuleLoadException Handler Exception

multithreading - 检测您何时进入/离开 Xamarin.iOS 中的主线程

node.js - NodeJS - libuv 线程池是全局的还是每个进程的?

c# - 在新的Thread()中等待是否毫无意义?

java - 使用接口(interface)实现将线程结果返回给Fragment

接收 cpp/cli 对象的 C# 类构造函数导致错误 'not supported by the language'