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.
27 lines
623 B
27 lines
623 B
#include<stdio.h>
|
|
#include<time.h>
|
|
#include<iostream>
|
|
#include<ostream>
|
|
#include<stdlib.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=(float*)malloc(SIZE*sizeof(float));
|
|
float *B=(float*)malloc(SIZE*sizeof(float));
|
|
float *C=(float*)malloc(SIZE*sizeof(float));
|
|
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();
|
|
std::cout<<"³õʼÏòÁ¿¼Ó·¨Ê±¼ä£º"<<double(end-start)/CLOCKS_PER_SEC<<"Ãë"<<std::endl;
|
|
|
|
|
|
}
|