From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 83D9F7ED45 for ; Sun, 24 Jun 2012 21:08:04 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AocBAJBk509KfVK2kGdsb2JhbABEtXQIIgEBAQEJCQ0HFAQjghgBAQEDARICLAEbEAoDAQMBCwYFCzsiAREBBQEcBi8Gh1oBAwYFmiwJA4wjgnGDeQoZJw1XiHEBBQyRKQOVLokmhH4+hAA X-IronPort-AV: E=Sophos;i="4.77,467,1336341600"; d="scan'208";a="164219762" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 24 Jun 2012 21:08:04 +0200 Received: by werg1 with SMTP id g1so3622167wer.27 for ; Sun, 24 Jun 2012 12:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+8gbOx9bzkndD65f1oGj5oHKNBwPr9ZseFKRP8SdMx4=; b=KxP8VFrMog3tAFLsCZPWrAKtHYS25k/DLSuirVdvDGUsY3yHE+/493FUCe7j2ErO9O QCy3po3U1JK3cAgxz5eDacXmDChW5+gBHM9lTODLQeG2/OOEFXAi2xUMPkNrQWzt23M5 CcoYLJE/9+Eq1ErNDTYj3cr8K/pZRPKmf3hDSuj0O0KcVWtwuO6wrwiObWbDzwl4BEMd v7qC14I+ZDA5idjhanZg4DnOT38JB7o+BvPloWxzArYPd5fnCKkcmpP94YZz9yOsh3lJ atvzSluS3qlYe4DGP6C8jy1JPjS8SqmnqdMZYnqP0uxrthExaFpNA7THKnuqe+GGu+k+ QV9Q== MIME-Version: 1.0 Received: by 10.216.218.144 with SMTP id k16mr4567070wep.215.1340564884066; Sun, 24 Jun 2012 12:08:04 -0700 (PDT) Received: by 10.217.1.8 with HTTP; Sun, 24 Jun 2012 12:08:04 -0700 (PDT) In-Reply-To: References: Date: Sun, 24 Jun 2012 21:08:04 +0200 Message-ID: From: Diego Olivier Fernandez Pons To: Gabriel Scherer Cc: caml-list Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] print_int is too slow 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