?? 負載平衡.cpp
字號:
// 負載平衡.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include"omp.h"
#include <windows.h>
void smallwork()
{
}
void bigwork()
{
_int64 sum = 0;
for(int i = 0; i < 100000000; i++)
sum += i;
}
int _tmain(int argc, _TCHAR* argv[])
{
_int64 counter_begin;
_int64 counter_end;
_int64 diff1,diff2,diff3;
QueryPerformanceCounter((LARGE_INTEGER*)&counter_begin);
for(int i = 0; i < 100; i++)
{
if(i < 50)
smallwork();
else
bigwork();
}
QueryPerformanceCounter((LARGE_INTEGER*)&counter_end);
diff1 = counter_end - counter_begin;
printf("count = %I64d\n",diff1);
QueryPerformanceCounter((LARGE_INTEGER*)&counter_begin);
#pragma omp parallel for
for(int i = 0; i < 100; i++)
{
if(i < 50)
smallwork();
else
bigwork();
}
QueryPerformanceCounter((LARGE_INTEGER*)&counter_end);
diff2 = counter_end - counter_begin;
printf("count = %I64d\n",diff2);
QueryPerformanceCounter((LARGE_INTEGER*)&counter_begin);
#pragma omp parallel for
for(int i = 0; i < 100; i++)
{
if(i % 2)
smallwork();
else
bigwork();
}
QueryPerformanceCounter((LARGE_INTEGER*)&counter_end);
diff3 = counter_end - counter_begin;
printf("count = %I64d\n",diff3);
//double r;
//r = (double)diff1/(double)diff3;
//printf("Accelerate = %I64d\n",r);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -