Re: [beagleboard] elapsed time microseconds c++
Whoops - finger troubles On Mon, Oct 7, 2013 at 8:16 PM, Dave Hylands wrote: > > Hi, > > > On Sat, Oct 5, 2013 at 2:31 AM, wrote: > > > > hi, > > > > Looks like there is something wrong in eclipse. I compiled the code gettimeofday directly from ubuntu terminal and it works properly. Also the code works in my beaglebone :-) > > > > BUT... :-S. I am trying to run my code. It compiles and run under ubuntu but when i try to run in in my beaglebone i got the error: > > -sh: ./hil: cannot execute binary file > > > > I am using the following command in my beaglebone: > > chmod ugo+x hil > > ./hil > > > > I am using this includes: > > stdio.h > > stdlib.h > > math.h > > sys/time.h > > > > any suggestion? thanks in advance to everybody > > Try using the "file" command on your program. It will tell whether you built an ARM executable or an x86 executable. x86 executables will produce the error you're seeing when you try to run them on the beagleboard (since the beagleboard uses an ARM processor). > > file ./hil > > For example: file /bin/ls on my x86 ubuntu machine shows: /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x37cdd635587f519989044055623abff939002027, stripped and file run on an executable for the beagleboad will typically show something like: bash: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped So as Tux mentioned, you're probably using the host compiler instead of the cross compiler to build your program. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
Hi, On Sat, Oct 5, 2013 at 2:31 AM, wrote: > > hi, > > Looks like there is something wrong in eclipse. I compiled the code gettimeofday directly from ubuntu terminal and it works properly. Also the code works in my beaglebone :-) > > BUT... :-S. I am trying to run my code. It compiles and run under ubuntu but when i try to run in in my beaglebone i got the error: > -sh: ./hil: cannot execute binary file > > I am using the following command in my beaglebone: > chmod ugo+x hil > ./hil > > I am using this includes: > stdio.h > stdlib.h > math.h > sys/time.h > > any suggestion? thanks in advance to everybody Try using the "file" command on your program. It will tell whether you built an ARM executable or an x86 executable. x86 executables will produce the error you're seeing when you try to run them on the beagleboard (since the beagleboard uses an ARM processor). file ./hil For example: file /bin/ls on my x86 ubuntu machine shows: -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
Did you use a crosscompiler? You can also compile your code on your beaglebone. 2013/10/5 > hi, > > Looks like there is something wrong in eclipse. I compiled the code > gettimeofday directly from ubuntu terminal and it works properly. Also the > code works in my beaglebone :-) > > BUT... :-S. I am trying to run my code. It compiles and run under ubuntu > but when i try to run in in my beaglebone i got the error: > -sh: ./hil: cannot execute binary file > > I am using the following command in my beaglebone: > chmod ugo+x hil > ./hil > > I am using this includes: > stdio.h > stdlib.h > math.h > sys/time.h > > any suggestion? thanks in advance to everybody > > > On Friday, October 4, 2013 5:33:04 PM UTC+2, ignacio...@gmail.com wrote: >> >> Hi, >> >> My big code compiles properly in eclipse. As you said I started with >> hello world and small codes. My problems became only measuring elapsed >> time. With small codes, just to measure elapsed time it still doesn't work. >> I tried with clock() as i said but the elapsed time showed in the terminal >> is wrong. Now I am trying with the code supplied by you, because i would >> like to try with gettimeofday but errors commented before. >> >> I will put my compiler, linker and assembler later. I am not in my >> personal computer now. >> >> really thanks for your help. >> >> El viernes, 4 de octubre de 2013 16:59:35 UTC+2, Dieter Wirz escribió: >>> >>> Hi Ignacio >>> On Fri, Oct 4, 2013 at 10:06 AM, wrote: >>> > My aim is program in ansi c my beaglebone black. I am using an ubuntu >>> vm under mac os. >>> > >>> > I am new in ubuntu and eclipse and this is the main problem, i guess >>> :-S >>> > >>> > I have a model that i would like to run into BB but i have problems to >>> measure the elapsed time, i tried before with clock(), but looks like it >>> doesn't measure properly the time. For this i am trying with gettimeofday, >>> but i have the problems that i commented previously. >>> > >>> > Looks like if eclipse could not link time.h and for this appear these >>> errors. But maybe i am wrong >>> Eclipse with an installed crosscompiler is only one way to go and it >>> certainly makes sense if you have a huge Project with thousands of >>> lines of code, X, etc. But I usually code only small terminal programs >>> (in ANSI C) that read in some ports, write to some ports, do some >>> calculations and write the results to a excel readable text file. For >>> such problems I am too lazy to install Eclipse with all the gnuaebi >>> etc. stuff >>> So, I edit and compile my programs directly on BB, usually over ssh >>> and sftp (usually from my Mac, with Cyberduck). The only thing you >>> need on BB is gcc and if you have a bit bigger projects make. >>> >>> Starting with "Hello World" is always a good idea >>> Connect to your BB with ssh >>> nano helloworld.c >>> type in your code, quit and save with "ctrl x" >>> gcc -Wall helloworld.c -o helloworld >>> And run your program with >>> ./helloworld >>> you need the ./ for running terminal programs in the same folder >>> >>> Have fun! >>> >> -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to beagleboard+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
hi, Looks like there is something wrong in eclipse. I compiled the code gettimeofday directly from ubuntu terminal and it works properly. Also the code works in my beaglebone :-) BUT... :-S. I am trying to run my code. It compiles and run under ubuntu but when i try to run in in my beaglebone i got the error: -sh: ./hil: cannot execute binary file I am using the following command in my beaglebone: chmod ugo+x hil ./hil I am using this includes: stdio.h stdlib.h math.h sys/time.h any suggestion? thanks in advance to everybody On Friday, October 4, 2013 5:33:04 PM UTC+2, ignacio...@gmail.com wrote: > > Hi, > > My big code compiles properly in eclipse. As you said I started with hello > world and small codes. My problems became only measuring elapsed time. With > small codes, just to measure elapsed time it still doesn't work. I tried > with clock() as i said but the elapsed time showed in the terminal is > wrong. Now I am trying with the code supplied by you, because i would like > to try with gettimeofday but errors commented before. > > I will put my compiler, linker and assembler later. I am not in my > personal computer now. > > really thanks for your help. > > El viernes, 4 de octubre de 2013 16:59:35 UTC+2, Dieter Wirz escribió: >> >> Hi Ignacio >> On Fri, Oct 4, 2013 at 10:06 AM, wrote: >> > My aim is program in ansi c my beaglebone black. I am using an ubuntu >> vm under mac os. >> > >> > I am new in ubuntu and eclipse and this is the main problem, i guess >> :-S >> > >> > I have a model that i would like to run into BB but i have problems to >> measure the elapsed time, i tried before with clock(), but looks like it >> doesn't measure properly the time. For this i am trying with gettimeofday, >> but i have the problems that i commented previously. >> > >> > Looks like if eclipse could not link time.h and for this appear these >> errors. But maybe i am wrong >> Eclipse with an installed crosscompiler is only one way to go and it >> certainly makes sense if you have a huge Project with thousands of >> lines of code, X, etc. But I usually code only small terminal programs >> (in ANSI C) that read in some ports, write to some ports, do some >> calculations and write the results to a excel readable text file. For >> such problems I am too lazy to install Eclipse with all the gnuaebi >> etc. stuff >> So, I edit and compile my programs directly on BB, usually over ssh >> and sftp (usually from my Mac, with Cyberduck). The only thing you >> need on BB is gcc and if you have a bit bigger projects make. >> >> Starting with "Hello World" is always a good idea >> Connect to your BB with ssh >> nano helloworld.c >> type in your code, quit and save with "ctrl x" >> gcc -Wall helloworld.c -o helloworld >> And run your program with >> ./helloworld >> you need the ./ for running terminal programs in the same folder >> >> Have fun! >> > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
Hi, My big code compiles properly in eclipse. As you said I started with hello world and small codes. My problems became only measuring elapsed time. With small codes, just to measure elapsed time it still doesn't work. I tried with clock() as i said but the elapsed time showed in the terminal is wrong. Now I am trying with the code supplied by you, because i would like to try with gettimeofday but errors commented before. I will put my compiler, linker and assembler later. I am not in my personal computer now. really thanks for your help. El viernes, 4 de octubre de 2013 16:59:35 UTC+2, Dieter Wirz escribió: > > Hi Ignacio > On Fri, Oct 4, 2013 at 10:06 AM, > > wrote: > > My aim is program in ansi c my beaglebone black. I am using an ubuntu vm > under mac os. > > > > I am new in ubuntu and eclipse and this is the main problem, i guess :-S > > > > I have a model that i would like to run into BB but i have problems to > measure the elapsed time, i tried before with clock(), but looks like it > doesn't measure properly the time. For this i am trying with gettimeofday, > but i have the problems that i commented previously. > > > > Looks like if eclipse could not link time.h and for this appear these > errors. But maybe i am wrong > Eclipse with an installed crosscompiler is only one way to go and it > certainly makes sense if you have a huge Project with thousands of > lines of code, X, etc. But I usually code only small terminal programs > (in ANSI C) that read in some ports, write to some ports, do some > calculations and write the results to a excel readable text file. For > such problems I am too lazy to install Eclipse with all the gnuaebi > etc. stuff > So, I edit and compile my programs directly on BB, usually over ssh > and sftp (usually from my Mac, with Cyberduck). The only thing you > need on BB is gcc and if you have a bit bigger projects make. > > Starting with "Hello World" is always a good idea > Connect to your BB with ssh > nano helloworld.c > type in your code, quit and save with "ctrl x" > gcc -Wall helloworld.c -o helloworld > And run your program with > ./helloworld > you need the ./ for running terminal programs in the same folder > > Have fun! > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
Hi Ignacio On Fri, Oct 4, 2013 at 10:06 AM, wrote: > My aim is program in ansi c my beaglebone black. I am using an ubuntu vm > under mac os. > > I am new in ubuntu and eclipse and this is the main problem, i guess :-S > > I have a model that i would like to run into BB but i have problems to > measure the elapsed time, i tried before with clock(), but looks like it > doesn't measure properly the time. For this i am trying with gettimeofday, > but i have the problems that i commented previously. > > Looks like if eclipse could not link time.h and for this appear these errors. > But maybe i am wrong Eclipse with an installed crosscompiler is only one way to go and it certainly makes sense if you have a huge Project with thousands of lines of code, X, etc. But I usually code only small terminal programs (in ANSI C) that read in some ports, write to some ports, do some calculations and write the results to a excel readable text file. For such problems I am too lazy to install Eclipse with all the gnuaebi etc. stuff So, I edit and compile my programs directly on BB, usually over ssh and sftp (usually from my Mac, with Cyberduck). The only thing you need on BB is gcc and if you have a bit bigger projects make. Starting with "Hello World" is always a good idea Connect to your BB with ssh nano helloworld.c type in your code, quit and save with "ctrl x" gcc -Wall helloworld.c -o helloworld And run your program with ./helloworld you need the ./ for running terminal programs in the same folder Have fun! -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
Could you provide us your source, the compiler/linker output and your compile command? 2013/10/4 > My aim is program in ansi c my beaglebone black. I am using an ubuntu vm > under mac os. > > I am new in ubuntu and eclipse and this is the main problem, i guess :-S > > I have a model that i would like to run into BB but i have problems to > measure the elapsed time, i tried before with clock(), but looks like it > doesn't measure properly the time. For this i am trying with gettimeofday, > but i have the problems that i commented previously. > > Looks like if eclipse could not link time.h and for this appear these > errors. But maybe i am wrong > > Really thanks to everybody for your help > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to beagleboard+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
My aim is program in ansi c my beaglebone black. I am using an ubuntu vm under mac os. I am new in ubuntu and eclipse and this is the main problem, i guess :-S I have a model that i would like to run into BB but i have problems to measure the elapsed time, i tried before with clock(), but looks like it doesn't measure properly the time. For this i am trying with gettimeofday, but i have the problems that i commented previously. Looks like if eclipse could not link time.h and for this appear these errors. But maybe i am wrong Really thanks to everybody for your help -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
On Thu, Oct 3, 2013 at 9:56 PM, wrote: > the issue is that i can not find gettimeofday.c in ubuntu. I only find You have to save the code I provided as gettimeofday.c. However, I do not see what this has to do with BB(B). Do you want to crosscompile with eclipse, or what are you intending to do??? -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
Hi, sorry it was my fault. I only have problems with: >>> Field "tv_sec" could not be resolved >>> Field "tv_usec" could not be resolved the issue is that i can not find gettimeofday.c in ubuntu. I only find /usr/share/man/man2/gettimeofday.2.gz sorry, i am quite new with this. how could i solve this issue? Thank you so much El miércoles, 2 de octubre de 2013 17:04:18 UTC+2, Tux Leonard escribió: > > The code works fine. Even with Eclipse. > > How is it posible that you get errors about cout, endl and std. Those > commands are not in the posted code. > > > 2013/10/2 Dieter Wirz > > >> On Tue, Oct 1, 2013 at 11:14 PM, > >> wrote: >> >>> hi, Sorry for disturbing you. How can I compile "gcc -Wall >> >>> gettimeofday.c -o gettimeofday " in eclipse under ubuntu? >> I don't know Eclipse too much, I compile such programs in terminal: >> Open Terminal >> cd to the folder where gettimeofday.c is >> type in: >> gcc -Wall gettimeofday.c -o gettimeofday >> run the Porgram with >> ./gettimeofday >> >> >>> I got some errors: >> >>> Field "tv_sec" could not be resolved >> >>> Field "tv_usec" could not be resolved >> >> Maybe you have to tell Eclipse: >> - it is C (not C++) >> - from where to include >> >> HTH >> >> -- >> For more options, visit http://beagleboard.org/discuss >> --- >> You received this message because you are subscribed to the Google Groups >> "BeagleBoard" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to beagleboard...@googlegroups.com . >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
The code works fine. Even with Eclipse. How is it posible that you get errors about cout, endl and std. Those commands are not in the posted code. 2013/10/2 Dieter Wirz > On Tue, Oct 1, 2013 at 11:14 PM, wrote: > >>> hi, Sorry for disturbing you. How can I compile "gcc -Wall > >>> gettimeofday.c -o gettimeofday " in eclipse under ubuntu? > I don't know Eclipse too much, I compile such programs in terminal: > Open Terminal > cd to the folder where gettimeofday.c is > type in: > gcc -Wall gettimeofday.c -o gettimeofday > run the Porgram with > ./gettimeofday > > >>> I got some errors: > >>> Field "tv_sec" could not be resolved > >>> Field "tv_usec" could not be resolved > > Maybe you have to tell Eclipse: > - it is C (not C++) > - from where to include > > HTH > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to beagleboard+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
On Tue, Oct 1, 2013 at 11:14 PM, wrote: >>> hi, Sorry for disturbing you. How can I compile "gcc -Wall >>> gettimeofday.c -o gettimeofday " in eclipse under ubuntu? I don't know Eclipse too much, I compile such programs in terminal: Open Terminal cd to the folder where gettimeofday.c is type in: gcc -Wall gettimeofday.c -o gettimeofday run the Porgram with ./gettimeofday >>> I got some errors: >>> Field "tv_sec" could not be resolved >>> Field "tv_usec" could not be resolved Maybe you have to tell Eclipse: - it is C (not C++) - from where to include HTH -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
On Tuesday, October 1, 2013 10:08:54 PM UTC+2, ignacio...@gmail.com wrote: > > > > On Tuesday, October 1, 2013 9:38:07 PM UTC+2, ignacio...@gmail.com wrote: >> >> >> >> On Tuesday, October 1, 2013 2:11:39 PM UTC+2, Dieter Wirz wrote: >>> >>> On Thu, Sep 26, 2013 at 9:36 PM, wrote: >>> > hello, >>> > >>> > I tried several ways ( clock(), gettimeofday()..) but I can get the >>> proper >>> > way to measure the elapsed time in microseconds. >>> > >>> > I am using eclipse to program in ansi c. Could anybody help me about >>> how to >>> > measure the elapsed time in microsecond? Could it be possible to >>> enclosed >>> > the code that I should use? >>> Ansi C or C++ (as in the title)? >>> In Ansi C it might look like this: >>> >>> #include >>> #include >>> // compile with: gcc -Wall gettimeofday.c -o gettimeofday >>> void main() >>> { >>> float elapsed_time; >>> struct timeval start_time, end_time; >>> gettimeofday( &start_time, NULL ); >>> for (;;){ >>> gettimeofday( &end_time, NULL ); >>> elapsed_time = end_time.tv_sec - start_time.tv_sec + ( >>> end_time.tv_usec - start_time.tv_usec ) / 1e6; >>> printf( "sec: %g \r", elapsed_time ); >>> } >>> } >>> >> >> >> >> >> >> hi, Sorry for disturbing you. How can I compile "gcc -Wall >> gettimeofday.c -o gettimeofday " in eclipse under ubuntu? >> >> I got some errors: >> Field "tv_sec" could not be resolved >> Field "tv_usec" could not be resolved >> >> >> Sorry for the inconveniences >> >> Regards >> > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
On Tuesday, October 1, 2013 9:38:07 PM UTC+2, ignacio...@gmail.com wrote: > > > > On Tuesday, October 1, 2013 2:11:39 PM UTC+2, Dieter Wirz wrote: >> >> On Thu, Sep 26, 2013 at 9:36 PM, wrote: >> > hello, >> > >> > I tried several ways ( clock(), gettimeofday()..) but I can get the >> proper >> > way to measure the elapsed time in microseconds. >> > >> > I am using eclipse to program in ansi c. Could anybody help me about >> how to >> > measure the elapsed time in microsecond? Could it be possible to >> enclosed >> > the code that I should use? >> Ansi C or C++ (as in the title)? >> In Ansi C it might look like this: >> >> #include >> #include >> // compile with: gcc -Wall gettimeofday.c -o gettimeofday >> void main() >> { >> float elapsed_time; >> struct timeval start_time, end_time; >> gettimeofday( &start_time, NULL ); >> for (;;){ >> gettimeofday( &end_time, NULL ); >> elapsed_time = end_time.tv_sec - start_time.tv_sec + ( >> end_time.tv_usec - start_time.tv_usec ) / 1e6; >> printf( "sec: %g \r", elapsed_time ); >> } >> } >> > > > > > > hi, Sorry for disturbing you. How can I compile "gcc -Wall gettimeofday.c > -o gettimeofday " in eclipse under ubuntu? > > I got some errors: > Field "tv_sec" could not be resolved > Field "tv_usec" could not be resolved > symbol "cout" could not be resolved > symbol "endl" could not be resolved > symbol "std" could not be resolved > > Sorry for the inconveniences > > Regards > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
On Tuesday, October 1, 2013 2:11:39 PM UTC+2, Dieter Wirz wrote: > > On Thu, Sep 26, 2013 at 9:36 PM, > > wrote: > > hello, > > > > I tried several ways ( clock(), gettimeofday()..) but I can get the > proper > > way to measure the elapsed time in microseconds. > > > > I am using eclipse to program in ansi c. Could anybody help me about how > to > > measure the elapsed time in microsecond? Could it be possible to > enclosed > > the code that I should use? > Ansi C or C++ (as in the title)? > In Ansi C it might look like this: > > #include > #include > // compile with: gcc -Wall gettimeofday.c -o gettimeofday > void main() > { > float elapsed_time; > struct timeval start_time, end_time; > gettimeofday( &start_time, NULL ); > for (;;){ > gettimeofday( &end_time, NULL ); > elapsed_time = end_time.tv_sec - start_time.tv_sec + ( > end_time.tv_usec - start_time.tv_usec ) / 1e6; > printf( "sec: %g \r", elapsed_time ); > } > } > hi, Sorry for disturbing you. How can I compile "gcc -Wall gettimeofday.c -o gettimeofday " in eclipse? I got some errors: Field "tv_sec" could not be resolved Field "tv_usec" could not be resolved symbol "cout" could not be resolved symbol "endl" could not be resolved symbol "std" could not be resolved Sorry for the inconveniences Regards -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
On Thu, Sep 26, 2013 at 9:36 PM, wrote: > hello, > > I tried several ways ( clock(), gettimeofday()..) but I can get the proper > way to measure the elapsed time in microseconds. > > I am using eclipse to program in ansi c. Could anybody help me about how to > measure the elapsed time in microsecond? Could it be possible to enclosed > the code that I should use? Ansi C or C++ (as in the title)? In Ansi C it might look like this: #include #include // compile with: gcc -Wall gettimeofday.c -o gettimeofday void main() { float elapsed_time; struct timeval start_time, end_time; gettimeofday( &start_time, NULL ); for (;;){ gettimeofday( &end_time, NULL ); elapsed_time = end_time.tv_sec - start_time.tv_sec + ( end_time.tv_usec - start_time.tv_usec ) / 1e6; printf( "sec: %g \r", elapsed_time ); } } -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
On 09/26/2013 09:31 PM, Nuno Sucena Almeida wrote: > > Hi, > use a search engine and look for "linux measure time nanoseconds". > Also: man clock_gettime > > regards, > Nuno > If you have C++11 , look for chrono, it might be easier http://en.cppreference.com/w/cpp/chrono regards, Nuno -- http://aeminium.org/nuno/ -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [beagleboard] elapsed time microseconds c++
On 09/26/2013 03:36 PM, ignacio.mata...@gmail.com wrote: > hello, > > I tried several ways ( clock(), gettimeofday()..) but I can get the proper > way to measure the elapsed time in microseconds. > > I am using eclipse to program in ansi c. Could anybody help me about how to > measure the elapsed time in microsecond? Could it be possible to enclosed > the code that I should use? > > thank you so much and sorry for the inconveniences > > Regards > Hi, use a search engine and look for "linux measure time nanoseconds". Also: man clock_gettime regards, Nuno -- http://aeminium.org/nuno/ -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.