caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Oliver Bandel" <oliver@first.in-berlin.de>
To: "Diego Olivier Fernandez Pons" <dofp.ocaml@gmail.com>
Cc: "Gabriel Scherer" <gabriel.scherer@gmail.com>,
	caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] print_int is too slow
Date: Sun, 24 Jun 2012 21:18:40 +0200	[thread overview]
Message-ID: <20120624211840.124466j26yxz6rkg@webmail.in-berlin.de> (raw)
In-Reply-To: <CAHqiZ-KRTmTC4196dikqj8B5t4F84xEJTONaX4+Ns2UhjgeJtQ@mail.gmail.com>

what about

print_string( string_of_int !length ^ "\n")

??




Zitat von "Diego Olivier Fernandez Pons" <dofp.ocaml@gmail.com>:

>     Gabriel,
>
>> I have no time for empirical checks right now, but is the problem
>> really with print_int, or does replacing (print_newline ()) by
>> (print_string "\n") similarly improves performances? That may very
>> well be related to when buffering happens.
>
> You are right, it's print_newline() that is causing the problem
>
> (> 2s) print_int !length; print_newline ()
> (0.27s) printf.printf "%i\n" !length
> (0.21s) print_int !length; print_string "\n"
>
> I know that is not much of a difference... but it's the IOI training
> exercises and time limits are hard.
> Besides on this case that difference was larger than what I could gain
> with smarter algorithms or better data structure (I tried a dozen
> variants)
>
>         Diego Olivier
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>



  reply	other threads:[~2012-06-24 19:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-24 18:40 Diego Olivier Fernandez Pons
2012-06-24 18:59 ` Gabriel Scherer
2012-06-24 19:08   ` Diego Olivier Fernandez Pons
2012-06-24 19:18     ` Oliver Bandel [this message]
2012-06-24 19:26       ` Diego Olivier Fernandez Pons
2012-06-24 19:48         ` Adrien
     [not found]         ` <20120624.220220.2022399462583597382.Christophe.Troestler@umons.ac.be>
2012-06-24 22:19           ` Diego Olivier Fernandez Pons
2012-06-24 23:06             ` Lukasz Stafiniak
2012-06-24 23:52               ` Anthony Tavener
2012-06-25  0:09               ` Diego Olivier Fernandez Pons
2012-06-25 11:39                 ` oliver
2012-06-25 13:04                   ` Gabriel Scherer
2012-06-25 14:25                     ` oliver
2012-06-25 17:31             ` Florian Weimer
2012-06-25 10:07     ` Goswin von Brederlow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120624211840.124466j26yxz6rkg@webmail.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@inria.fr \
    --cc=dofp.ocaml@gmail.com \
    --cc=gabriel.scherer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).