-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixMultiplication.cpp
More file actions
50 lines (39 loc) · 1.22 KB
/
MatrixMultiplication.cpp
File metadata and controls
50 lines (39 loc) · 1.22 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "MatrixMultiplication.h"
// C++ program to find out execution time of
// of functions
#include <algorithm>
#include <chrono>
#include <iostream>
#include<vector>
using namespace std;
using namespace std::chrono;
// For demonstration purpose, we will fill up
// a vector with random integers and then sort
// them using sort function. We fill record
// and print the time required by sort function
int main()
{
M<uint8_t> left(3,3);
cout << "Initialized left \n" << left;
// Generate Random values
auto f = []() -> uint8_t {
return rand() % 256;
};
// Fill up the vector
generate(left.begin(), left.end(), f);
cout << "\nFilled left\n" << left;
// Get starting timepoint
auto start = high_resolution_clock::now();
// Call the function, here sort()
M<uint8_t> result = multiplyMatrix(&left, &left);
// Get ending timepoint
auto stop = high_resolution_clock::now();
// Get duration. Substart timepoints to
// get duration. To cast it to proper unit
// use duration cast method
auto duration = duration_cast<microseconds>(stop - start);
cout << "Time taken by function: "
<< duration.count() << " microseconds" << endl;
return 0;
}