Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #18043

Re: C language paradox

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: C language paradox
Date 2012-02-29 10:44 +1300
Message-ID <9r505hFcg8U5@mid.individual.net> (permalink)
References <jijh7o$i5c$1@speranza.aioe.org>

Show all headers | View raw


On 02/29/12 10:33 AM, pembed2012 wrote:
> Hello again
> I continue to read about optimization in C.
>
> I saw that we shall always uses puts instead of printf for a constant
> string. However I made the following experiments:
>
>        routine:      for(i = 0;i<  100; i++) printf("\n");

This outputs one newline.  It will probably be optimised to a putchar().

>             time: 0.38 seconds
>
>        routine:      for(i = 0;i<  100: i++) puts("\n");

This outputs two newlines.

 >
 > Conclusion: printf is more efficient than puts.

Conclusion: outputting two characters takes longer than outputting one.

-- 
Ian Collins

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

C language paradox pembed2012 <once@was.enough.invalid> - 2012-02-28 21:33 +0000
  Re: C language paradox Willem <willem@toad.stack.nl> - 2012-02-28 21:41 +0000
  Re: C language paradox Ian Collins <ian-news@hotmail.com> - 2012-02-29 10:44 +1300
  Re: C language paradox Shao Miller <sha0.miller@gmail.com> - 2012-02-28 16:51 -0500
  Re: C language paradox Kaz Kylheku <kaz@kylheku.com> - 2012-02-28 22:16 +0000
    Re: C language paradox Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-29 01:34 -0800
      Re: C language paradox James Kuyper <jameskuyper@verizon.net> - 2012-02-29 07:18 -0500
        Re: C language paradox "Scott Fluhrer" <sfluhrer@ix.netcom.com> - 2012-02-29 13:39 -0500
          Re: C language paradox Kenneth Brody <kenbrody@spamcop.net> - 2012-03-03 16:23 -0500
            Re: C language paradox James Kuyper <jameskuyper@verizon.net> - 2012-03-03 19:47 -0500
              Re: C language paradox Geoff <geoff@invalid.invalid> - 2012-03-03 18:05 -0800
                Re: C language paradox Kenneth Brody <kenbrody@spamcop.net> - 2012-03-05 15:41 -0500
                Re: C language paradox Robert Miles <milesrf@Usenet-News.net> - 2012-04-14 00:26 -0500
  Re: C language paradox James Kuyper <jameskuyper@verizon.net> - 2012-02-28 17:38 -0500
    Re: C language paradox Stephen Sprunk <stephen@sprunk.org> - 2012-02-28 18:52 -0600
      Re: C language paradox James Kuyper <jameskuyper@verizon.net> - 2012-02-28 22:14 -0500
  Re: C language paradox James Dow Allen <jdallen2000@yahoo.com> - 2012-02-28 15:08 -0800
    Re: C language paradox "io_x" <a@b.c.invalid> - 2012-02-29 03:42 +0100
    Re: C language paradox Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-29 01:37 -0800
      Re: C language paradox jgharston <jgh@arcade.demon.co.uk> - 2012-03-03 16:17 -0800
        Re: C language paradox nick_keighley_nospam@hotmail.com - 2012-03-04 02:54 -0800
          Re: C language paradox "BartC" <bc@freeuk.com> - 2012-03-04 11:43 +0000
          Re: C language paradox Keith Thompson <kst-u@mib.org> - 2012-03-04 04:01 -0800
            Re: C language paradox Nomen Nescio <nobody@dizum.com> - 2012-03-04 14:34 +0100
        Re: C language paradox Kaz Kylheku <kaz@kylheku.com> - 2012-03-04 17:01 +0000
          Re: C language paradox Kenneth Brody <kenbrody@spamcop.net> - 2012-03-05 15:45 -0500
  Re: C language paradox Keith Thompson <kst-u@mib.org> - 2012-02-28 17:45 -0800
    Re: C language paradox army1987 <army1987@ask-for-it.invalid> - 2012-03-05 10:42 +0000
      Re: C language paradox army1987 <army1987@ask-for-it.invalid> - 2012-03-05 10:48 +0000
        Re: C language paradox Keith Thompson <kst-u@mib.org> - 2012-03-05 09:35 -0800
          Re: C language paradox 88888 Dihedral <dihedral88888@googlemail.com> - 2012-04-16 13:01 -0700
      Re: C language paradox China Blue Water Navy <chine.bleu@yahoo.com> - 2012-03-05 04:24 -0800
      Re: C language paradox Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-03-05 07:49 -0500
  Re: C language paradox "io_x" <a@b.c.invalid> - 2012-02-29 03:42 +0100
  Re: C language paradox Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-02-28 21:46 -0500

csiph-web