From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.devel Subject: Re: Extremly slow for format & string-join Date: Mon, 01 Apr 2013 13:55:48 +0100 Message-ID: <87bo9ybeaz.fsf@Kagami.home> References: <1364788801.4639.6.camel@Renee-desktop.suse> <87obdy3aw9.fsf@tines.lan> <1364809930.4639.17.camel@Renee-desktop.suse> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1364820967 24819 80.91.229.3 (1 Apr 2013 12:56:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Apr 2013 12:56:07 +0000 (UTC) Cc: guile-devel@gnu.org To: Nala Ginrut Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Apr 01 14:56:31 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UMeHm-00058F-1m for guile-devel@m.gmane.org; Mon, 01 Apr 2013 14:56:30 +0200 Original-Received: from localhost ([::1]:43824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMeHN-0000pP-Kp for guile-devel@m.gmane.org; Mon, 01 Apr 2013 08:56:05 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMeHH-0000o4-34 for guile-devel@gnu.org; Mon, 01 Apr 2013 08:56:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMeHD-00017w-Vm for guile-devel@gnu.org; Mon, 01 Apr 2013 08:55:59 -0400 Original-Received: from mail-wg0-f45.google.com ([74.125.82.45]:60020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMeHD-00017h-P8 for guile-devel@gnu.org; Mon, 01 Apr 2013 08:55:55 -0400 Original-Received: by mail-wg0-f45.google.com with SMTP id x12so2014486wgg.0 for ; Mon, 01 Apr 2013 05:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:from:to:cc:subject:references:date:message-id:user-agent :mime-version:content-type; bh=rmn4mIOmz9sAw9bjMUNFbeT/nti1X9VBfLGevyyE9Fw=; b=WRjDcbrYPtUw8Bg3H8PTm22e7Ml7M0ft4CmaZxoxcdIP7DZAdJIbIg1LdGI97NoMMJ raHMSkWCA23LtBZNfgd6cSJIq+xbVP0MbB6Ub9z1oIkDkJGXWIZzeY9tIAOdauMGmxu9 lutAqRI5HnstGsJroqJkDcAK10WWQzjg+rUncIrGHx79CBic7AkT0V4pUxlo8A6NxI4r aau0Ft40k4m18hiuMzWqBaHuLw1PO3YSoM3aNr0x/hueZtwKWjygafhMpmn30KLFFfDo /Onp2skjTFKId1ByaDfIosdWU7xWwqAjOQrzq079FeXMEwvvYuJL6UCMVA0UmHH6YS5h SlOA== X-Received: by 10.180.94.135 with SMTP id dc7mr9801009wib.11.1364820954535; Mon, 01 Apr 2013 05:55:54 -0700 (PDT) Original-Received: from Kagami.home (host31-53-168-237.range31-53.btcentralplus.com. [31.53.168.237]) by mx.google.com with ESMTPS id f1sm14864609wib.0.2013.04.01.05.55.52 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 01 Apr 2013 05:55:53 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 74.125.82.45 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16092 Archived-At: Nala Ginrut writes: > string-join is a common thing for text processing(include web develop). > However, our powerful 'format' is not so efficient. I do think it's > necessary to we spend some time on it. As Mark says, format is a not very nice piece of code to read, or to modify, so if you want it faster, it'll be on you to implement I'm afraid. One thing you might be interested in though, is Alex Shinn's fmt library[0] (available on guildhall as wak-fmt), which is quite nice. (import (wak fmt)) (define (repeat formatter n) ;; I could probably make this a little faster, if I knew the internal ;; representation of format combinators, and didn't build the list (apply-cat (make-list n formatter))) (define (str* str n) ;; spends the bulk of its time in display (fmt #f (repeat str n))) It is not as competitive as Mark's improvements to string-join (5/6 seconds versus 4/5 milliseconds), but it's a hell of a lot faster than format, and it works on any arbitrary fmt formatter. I think we can take this as bearing out the well known speed differences of custom hardware/software (string-join) vs compilation (fmt) vs interpretation (format). :) 0. http://synthcode.com/scheme/fmt -- Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"