top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to analyze Runtime of printf() function?

0 votes
273 views
How to analyze Runtime of printf() function?
posted Jun 24, 2014 by Rahul Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

When we trying to analyze the runtime of printf, the algorithm that formats the string
is not going to be the performance bottleneck. Printf is a blocking function, meaning that it waits
until whatever it's printing has actually displayed before the execution of the program is resumed.
The performance of printf is mostly dependant on what type of console we displaying to. I did a test with a simple program:

#include <stdio.h>

int main()
{
  for (int i = 0; i < 1000000; i++) // 1 million iterations
    printf("hello, world\n");
  return 0;
}
answer Jun 25, 2014 by Vrije Mani Upadhyay
...