[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Extremly slow for format & string-join
From: |
Nala Ginrut |
Subject: |
Extremly slow for format & string-join |
Date: |
Mon, 01 Apr 2013 12:00:01 +0800 |
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 slow when N is large (> 1000000).
For 'format':
================profile==============
time seconds seconds name
73.90 1089.05 1089.04 length
23.61 347.92 347.92 list-tail
0.78 1473.57 11.46 format:format-work
0.60 8.84 8.84 get-output-string
0.28 4.15 4.15 display
=================end=================
For 'string-join', is shows that the C implementation of string-join is
the bottleneck.
I have no time to dig into, just report it.
Regards.
- Extremly slow for format & string-join,
Nala Ginrut <=
Re: Extremly slow for format & string-join, Mark H Weaver, 2013/04/01
Re: Extremly slow for format & string-join, Thien-Thi Nguyen, 2013/04/01