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 274A27ED45 for ; Mon, 25 Jun 2012 12:07:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiMCACM36E/U4w8ElGdsb2JhbABEtiAiAQEBAQkJCwkSKYIYAQEEAToyCgMFCwshJQ8BBA0bIRMch2ABAwYJrh8fKw2JTopQhmUDmnGDY4Fch2A X-IronPort-AV: E=Sophos;i="4.77,471,1336341600"; d="scan'208";a="164319828" Received: from mout.web.de ([212.227.15.4]) by mail1-smtp-roc.national.inria.fr with ESMTP; 25 Jun 2012 12:07:22 +0200 Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0LaTid-1S0vhA08tz-00lttU; Mon, 25 Jun 2012 12:07:19 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1Sj6CT-00084k-94; Mon, 25 Jun 2012 12:07:17 +0200 From: Goswin von Brederlow To: Diego Olivier Fernandez Pons Cc: Gabriel Scherer , caml-list References: Date: Mon, 25 Jun 2012 12:07:17 +0200 In-Reply-To: (Diego Olivier Fernandez Pons's message of "Sun, 24 Jun 2012 21:08:04 +0200") Message-ID: <87lijb1z8q.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Provags-ID: V02:K0:DLP9b/Ib7t/K0yWyN+B3kRTUqWH1tZNIVSw3yIjT010 awDGuyFnAgqknCTW6m+WBQV4vwsCvJrPlSxZdZqYIngl29ZNoA jd540L+SIZqZ8TYE1wn/5UBaqKCVEfM4LD/6egmOvOYJQBmNeG IIgV5aAW2GRNKeL5f28+T6ct37vzynCaorhPy1OIkoiiUsE4Yi 5mnDlDv8stontXu0e6ZGw== Subject: Re: [Caml-list] print_int is too slow Diego Olivier Fernandez Pons writes: > 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 What about printf.printf "%i\n%!" !length? Is that just as slow as print_newline ()? If so then it truely is just the flushing of buffers. MfG Goswin