Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of c_and_asm by
main.cpp
00001 #include "mbed.h" 00002 #include <stdio.h> /* printf, fgets */ 00003 #include <stdlib.h> /* atoi */ 00004 00005 Timer t; 00006 Serial pc(USBTX, USBRX); 00007 00008 extern "C" int mult_asm(int a, int b); 00009 extern "C" int mult_c(int c, int d); 00010 00011 int main() { 00012 for (int k=20;k<300;k+=10){ 00013 int COUNT=k; 00014 int A [COUNT], B[COUNT],C[COUNT]; 00015 00016 for (int i=0;i<COUNT;i++){ 00017 A[i]=(int)rand()/ 1000000; 00018 B[i]=(int)rand()/ 1000000; 00019 } 00020 printf("Assembler: "); 00021 printf("%d \n",k); 00022 t.start(); 00023 00024 for (int i=0;i<COUNT;i++){ 00025 C[i]=mult_asm(A[i], B[i]); 00026 } 00027 t.stop(); 00028 for (int i=0;i<COUNT;i++){ 00029 printf("%d ",C[i]); 00030 } 00031 00032 printf("\nThe time taken was %f seconds\n", t.read()); 00033 00034 t.reset(); 00035 00036 printf("C :"); 00037 t.start(); 00038 00039 for (int i=0;i<COUNT;i++){ 00040 C[i]=mult_c(A[i], B[i]); 00041 } 00042 t.stop(); 00043 00044 for (int i=0;i<COUNT;i++){ 00045 printf("%d ",C[i]); 00046 } 00047 printf("\nThe time taken was %f seconds\n\n", t.read()); 00048 } 00049 }
Generated on Thu Jul 21 2022 03:06:40 by
1.7.2
