小编J. *_*Bug的帖子

多线程在速度上没有任何改进 - 在C中使用pthread - 为什么?

为了在多线程中变得更加舒适,我编写了一个带有"密集"计算的小程序.它是mandelbrot集的图片,其中每个像素单独计算,然后像素缓冲到行.每个线程获得的总行数相等.因此,例如,如果选择的线程数是2,则具有1000行高度计算的图片应该以两个500行包结束.因此我建议速度种类减少两倍,但没有改善.为什么???我不明白,因为一切正常并且看似合乎逻辑.如果有人能给我一个提示,我将非常感激.下面你会看到main和一个由main调用的mandelbrot集的caluclation函数.

int main(int argc, char ** argv, char ** envp) {

if(argc != 4)
{
printf("Bitte genau 3 Argumente eingeben.\n");
 return 1;
}
//Structs und Variablen für die Stopuhr
struct timeval start, ende;
long ttlende, ttlstart;

width  = str2num(argv[1]);
height = str2num(argv[2]);

int y;
//char blueGreenRed[3];
//Ist Buffer für ganze Zeile: Breite * 3 wegen den 3 Bytes pro Pixel
//char zeile[width*3];

unsigned char info[BMPHEADER_SIZE] = {
              //size
    'B','M',  0,0,0,0, 0,0, 0,0, 54,0,0,0,
              //width  //height
    40,0,0,0, 0,0,0,0, 0,0,0,0,  1,0, 24,0, …
Run Code Online (Sandbox Code Playgroud)

c multithreading pthreads performance-testing

0
推荐指数
1
解决办法
430
查看次数

标签 统计

c ×1

multithreading ×1

performance-testing ×1

pthreads ×1