You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
607 B
28 lines
607 B
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
#define SIZE 1024
|
|
|
|
void vector_add(float* A, float* B, float* C, int size) {
|
|
for (int i = 0; i < size; ++i) {
|
|
C[i] = A[i] + B[i];
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
float A[SIZE], B[SIZE], C[SIZE];
|
|
for (int i = 0; i < SIZE; ++i) {
|
|
A[i] = rand() % 100;
|
|
B[i] = rand() % 100;
|
|
}
|
|
clock_t start = clock();
|
|
vector_add(A, B, C, SIZE);
|
|
clock_t end = clock();
|
|
double time_used = ((double)(end - start)) / CLOCKS_PER_SEC;
|
|
printf("ÏòÁ¿¼Ó·¨ºÄʱ: %.6f Ãë\n", time_used);
|
|
|
|
return 0;
|
|
}
|
|
|