Re: Extremly slow for format & string-join

2013-04-02 Thread Ludovic Courtès
Mark H Weaver skribis: > Indeed, the implementation of 'string-join' was very bad: about O(n^2) [...] > Before: > > scheme@(guile-user)> ,time (define s (string-join (make-list 1 "test") > "-")) > ;; 0.998800s real time, 0.996677s run time. 0.984885s spent in GC. > scheme@(guile-user)> ,t

Re: array-copy! is slow & array-map.c (was: Extremly slow for format & string-join)

2013-04-02 Thread Daniel Llorens
Hello, sorry for the repeated message earlier. Ok, i think it's clear that all these double indirections can be eliminated globally by composing the strides of the array descriptor with the stride of SCM_I_ARRAY_V (array) and using that directly in the array descriptor. Is there any reason n

Re: array-copy! is slow & array-map.c (was: Extremly slow for format & string-join)

2013-04-02 Thread Daniel Llorens
This patch is for array-for-each. Only the first argument. Before: scheme@(guile-user)> (define a (make-array 1 100 10)) scheme@(guile-user)> ,time (let ((x 0)) (array-for-each (lambda (a) (set! x (+ a x))) a) x) $8 = 1000 ;; 0.621887s real time, 0.620181s run time. 0.00s spent in

Re: array-copy! is slow & array-map.c (was: Extremly slow for format & string-join)

2013-04-02 Thread Daniel Llorens
On Apr 2, 2013, at 12:19, Daniel Llorens wrote: > On Apr 1, 2013, at 19:15, Daniel Llorens wrote: > >> Third, none of the above are causing the slowness of array-copy!. I noticed >> that there's a double indirection in racp(). The second patch removes it. >> Actually this double indirection go

Re: array-copy! is slow & array-map.c (was: Extremly slow for format & string-join)

2013-04-02 Thread Daniel Llorens
On Apr 2, 2013, at 12:19, Daniel Llorens wrote: > On Apr 1, 2013, at 19:15, Daniel Llorens wrote: > >> Third, none of the above are causing the slowness of array-copy!. I noticed >> that there's a double indirection in racp(). The second patch removes it. >> Actually this double indirection go

Re: array-copy! is slow & array-map.c (was: Extremly slow for format & string-join)

2013-04-02 Thread Daniel Llorens
On Apr 1, 2013, at 19:15, Daniel Llorens wrote: > Third, none of the above are causing the slowness of array-copy!. I noticed > that there's a double indirection in racp(). The second patch removes it. > Actually this double indirection goes on all over array-map.c and I don't > understand why

array-copy! is slow & array-map.c (was: Extremly slow for format & string-join)

2013-04-01 Thread Daniel Llorens
> Message: 5 > Date: Mon, 1 Apr 2013 15:40:48 +0800 > From: Daniel Hartwig > To: guile-devel@gnu.org > Subject: Re: Extremly slow for format & string-join > On 1 April 2013 14:59, Daniel Llorens wrote: >> How can it be slower to allocate the result at once? >

Re: Extremly slow for format & string-join

2013-04-01 Thread Ian Price
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

Re: Extremly slow for format & string-join

2013-04-01 Thread Thien-Thi Nguyen
() Nala Ginrut () Mon, 01 Apr 2013 12:00:01 +0800 (define (str* str n) (format #f "~{~a~}" (make-list n str))) (define (str* str n) (string-join (make-list n str) "")) Here's another implementation, using SRFI 13 ‘xsubstring’: (define (str* str n) (xsubstring str 0 (* n (stri

Re: Extremly slow for format & string-join

2013-04-01 Thread Nala Ginrut
On Mon, 2013-04-01 at 04:36 -0400, Mark H Weaver wrote: > Nala Ginrut writes: > > > I've tried to implement a function to mimic string multiply like Python: > > "asdf" * 10 > > > > --code > > (define (str* str n) > > (format #f "~{~a~}" (make-list n str))) > > > > or

Re: Extremly slow for format & string-join

2013-04-01 Thread Mark H Weaver
Nala Ginrut writes: > I've tried to implement a function to mimic string multiply like Python: > "asdf" * 10 > > --code > (define (str* str n) > (format #f "~{~a~}" (make-list n str))) > > or > > (define (str* str n) > (string-join (make-list n str) "")) >

Re: Extremly slow for format & string-join

2013-04-01 Thread Daniel Hartwig
On 1 April 2013 14:59, Daniel Llorens wrote: > > Hello, > >> From: Daniel Hartwig >> >> (define (str* str n) >> (call-with-output-string >>(lambda (p) >> (let lp ((n n)) >>(unless (zero? n) >> (display str p) >> (lp (1- n))) >> >> Out of curiousity, how doe

Re: Extremly slow for format & string-join

2013-04-01 Thread Daniel Hartwig
On 1 April 2013 14:58, Nala Ginrut wrote: > On Mon, 2013-04-01 at 13:35 +0800, Daniel Hartwig wrote: >> 2013/4/1 Nala Ginrut : >> > Anyway, string-join is so slowly beyond my expectation. >> >> Also note that ‘string-concatenate’ (less general than ‘string-join’) >> performs better for the same ca

Re: Extremly slow for format & string-join

2013-04-01 Thread Daniel Llorens
Hello, > From: Daniel Hartwig > > 2013/4/1 Nala Ginrut : >> I've tried to implement a function to mimic string multiply like Python: >> "asdf" * 10 >> >> --code >> (define (str* str n) >> (format #f "~{~a~}" (make-list n str))) >> >> or >> >> (define (str* str n)

Re: Extremly slow for format & string-join

2013-03-31 Thread Nala Ginrut
On Mon, 2013-04-01 at 13:35 +0800, Daniel Hartwig wrote: > 2013/4/1 Nala Ginrut : > > Anyway, string-join is so slowly beyond my expectation. > > Also note that ‘string-concatenate’ (less general than ‘string-join’) > performs better for the same case, you could use that directly instead > of my p

Re: Extremly slow for format & string-join

2013-03-31 Thread Daniel Hartwig
2013/4/1 Nala Ginrut : > Anyway, string-join is so slowly beyond my expectation. Also note that ‘string-concatenate’ (less general than ‘string-join’) performs better for the same case, you could use that directly instead of my prior suggestion for similar results. Especially since you do not des

Re: Extremly slow for format & string-join

2013-03-31 Thread Nala Ginrut
On Mon, 2013-04-01 at 12:39 +0800, Daniel Hartwig wrote: > 2013/4/1 Nala Ginrut : > > I've tried to implement a function to mimic string multiply like Python: > > "asdf" * 10 > > > > --code > > (define (str* str n) > > (format #f "~{~a~}" (make-list n str))) > > > > or

Re: Extremly slow for format & string-join

2013-03-31 Thread Daniel Hartwig
2013/4/1 Nala Ginrut : > I've tried to implement a function to mimic string multiply like Python: > "asdf" * 10 > > --code > (define (str* str n) > (format #f "~{~a~}" (make-list n str))) > > or > > (define (str* str n) > (string-join (make-list n str) "")) > ---

Extremly slow for format & string-join

2013-03-31 Thread Nala Ginrut
I've tried to implement a function to mimic string multiply like Python: "asdf" * 10 --code (define (str* str n) (format #f "~{~a~}" (make-list n str))) or (define (str* str n) (string-join (make-list n str) "")) --end- Both are very