Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Timer

Altera_Forum
Honored Contributor II
817 Views

HI 

 

Please I need ur help  

I wanna print :'HELLO WORD " 100000 TIMES and then I wanna print how many time it takes 

 

thank u
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
124 Views

Hi, 

Check Following code, 

#include <stdio.h># include <time.h> int main() { // Calculate the time taken by fun() clock_t t; t = clock(); for(int i=0;i<100000;i++) { printf("HELLO WORD %d\n",i); } t = clock() - t; double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds printf("loop() took %f seconds to execute \n", time_taken); return 0; } 

 

Result:  

HELLO WORD 99997 HELLO WORD 99998 HELLO WORD 99999 loop() took 0.156086 seconds to execute  

Best Regards 

Vikas Jathar  

(This message was posted on behalf of Intel Corporation)
Reply