61 lines
1.8 KiB
C
61 lines
1.8 KiB
C
#include "graph.h"
|
|
#include "matrix.h"
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
|
|
void benchmark() {
|
|
const uint64_t row_length1 = 100;
|
|
const uint64_t column_length1 = 100;
|
|
uint64_t matrix1[row_length1][column_length1];
|
|
|
|
const uint64_t row_length2 = 100;
|
|
const uint64_t column_length2 = 100;
|
|
uint64_t matrix2[row_length2][column_length2];
|
|
|
|
uint64_t new_matrix[row_length1][column_length2];
|
|
|
|
double elapsed_time = 0.0;
|
|
const uint64_t iterations = 10000;
|
|
clock_t start_time;
|
|
|
|
for (uint64_t i = 0; i < iterations; i++) {
|
|
random_adjacency(row_length1, column_length1, matrix1);
|
|
random_adjacency(row_length2, column_length2, matrix2);
|
|
|
|
start_time = clock();
|
|
|
|
matrix_multiply_basic(row_length1, column_length1, matrix1,
|
|
row_length2, column_length2, matrix2,
|
|
new_matrix);
|
|
|
|
elapsed_time += (double)(clock() - start_time) / CLOCKS_PER_SEC;
|
|
}
|
|
|
|
printf("%lu iterations of matrix_multiply_basic took roughly %f seconds\n", iterations, elapsed_time);
|
|
printf("1 iteration of matrix_multiply_basic took on average roughly %f seconds\n", elapsed_time/iterations);
|
|
}
|
|
|
|
void test() {
|
|
const uint64_t row_length1 = 5;
|
|
const uint64_t column_length1 = 5;
|
|
uint64_t matrix1[row_length1][column_length1];
|
|
|
|
read_csv("csv/graph.csv", row_length1, column_length1, matrix1);
|
|
|
|
// print_matrix(row_length1, column_length1, matrix1);
|
|
|
|
// uint64_t new_matrix[row_length1][column_length1];
|
|
//
|
|
// matrix_multiply_basic(row_length1, column_length1, matrix1,
|
|
// row_length1, column_length1, matrix1,
|
|
// new_matrix);
|
|
//
|
|
// print_matrix(row_length1, column_length1, new_matrix);
|
|
}
|
|
|
|
int main(void) {
|
|
test();
|
|
// benchmark();
|
|
}
|