unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Ian Price <ianprice90@googlemail.com>
To: Nala Ginrut <nalaginrut@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: Extremly slow for format & string-join
Date: Mon, 01 Apr 2013 13:55:48 +0100	[thread overview]
Message-ID: <87bo9ybeaz.fsf@Kagami.home> (raw)
In-Reply-To: 1364809930.4639.17.camel@Renee-desktop.suse

Nala Ginrut <nalaginrut@gmail.com> 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"



  reply	other threads:[~2013-04-01 12:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-01  4:00 Extremly slow for format & string-join Nala Ginrut
2013-04-01  4:39 ` Daniel Hartwig
2013-04-01  5:13   ` Nala Ginrut
2013-04-01  5:35     ` Daniel Hartwig
2013-04-01  6:58       ` Nala Ginrut
2013-04-01  7:02         ` Daniel Hartwig
2013-04-01  8:36 ` Mark H Weaver
2013-04-01  9:52   ` Nala Ginrut
2013-04-01 12:55     ` Ian Price [this message]
2013-04-02 15:56   ` Ludovic Courtès
2013-04-01 10:37 ` Thien-Thi Nguyen
     [not found] <mailman.1257260.1364793213.854.guile-devel@gnu.org>
2013-04-01  6:59 ` Daniel Llorens
2013-04-01  7:40   ` Daniel Hartwig

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=87bo9ybeaz.fsf@Kagami.home \
    --to=ianprice90@googlemail.com \
    --cc=guile-devel@gnu.org \
    --cc=nalaginrut@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 read-only IMAP folder(s) and NNTP newsgroup(s).