swap_ararym.c |
| #include <stdio.h> #include <stdlib.h> #include <time.h> extern void swap_array (int ,int *); extern void cswap_array (int ,int *); main(){ int a[] = {1,2}; clock_t t1,t2; int length=1000000; int i; printf("Please input the test size:\n>"); scanf("%d", &length); t1=clock(); cswap_array(length, a); t2=clock(); printf("time for %d C swaps:\t %.6lf seconds\n\n",length, ((double)t2-t1)/CLOCKS_PER_SEC); t1=clock(); swap_array(length, a); t2=clock(); printf("time for %d assembler swaps:\t %.6lf seconds\n",length, ((double)t2-t1)/CLOCKS_PER_SEC); return 0; } |
James Little |