-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallel1.2.cpp
More file actions
29 lines (28 loc) · 957 Bytes
/
Copy pathparallel1.2.cpp
File metadata and controls
29 lines (28 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
#include <windows.h>
using namespace std;
int main()
{
LARGE_INTEGER head, tail, freq; // timers
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&head);
int n;
n = 101;
int a[1001][1101]; int b[1101];
int sum[1001];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
a[i][j] = i + j;
for (int i = 1; i <= n; i++)
b[i] = i;
for (int i = 1; i <= n; i++)
sum[i] = 0;
for (int j = 1; j <= n; j++)
for (int i = 1; i <= n; i++)
sum[i] += a[j][i] * b[j];
QueryPerformanceCounter(&tail);
int second_time = (double)(tail.QuadPart - head.QuadPart) / (double)(freq.QuadPart);
int micro_time = (double)(tail.QuadPart - head.QuadPart) / (double)(freq.QuadPart) * 1e6;
cout << "The total time of the project is :" << second_time << " s and " << micro_time << " ms" << endl;
return 0;
}