Darren Hoo darren@gmail.com writes:
It is way too slow to read numbers from a file simply by using `read'
for example a txt file contains 10,000,000 line of numbers:
To get speed, I would:
1- open a binary file,
2- perform double-buffering I/O, (ie. read a buffer while you process
Date: Sun, 01 Sep 2013 22:55:56 +0200
From: Pascal J. Bourguignon p...@informatimago.com
To: guile-user@gnu.org
Darren Hoo darren@gmail.com writes:
It is way too slow to read numbers from a file simply by using `read'
for example a txt file contains 10,000,000 line of numbers:
On Sat 31 Aug 2013 12:19, l...@gnu.org (Ludovic Courtès) writes:
Andy Wingo wi...@pobox.com skribis:
I just took a look at your program, which ran in 40s on my machine.
Under callgrind it turned out that we were doing a lot of iconv stuff
that we didn't need to do.
It’s often the case that
Andy Wingo wi...@pobox.com skribis:
On Sat 31 Aug 2013 12:19, l...@gnu.org (Ludovic Courtès) writes:
Andy Wingo wi...@pobox.com skribis:
I just took a look at your program, which ran in 40s on my machine.
Under callgrind it turned out that we were doing a lot of iconv stuff
that we didn't
Darren Hoo darren@gmail.com writes:
It is way too slow to read numbers from a file simply by using `read'
Indeed. Looking at the code, I can see a lot of room for improvement,
especially in 'string-number' (which is used also by 'read'). I've
added an item to my TODO list to optimize
On Sat 31 Aug 2013 05:55, Darren Hoo darren@gmail.com writes:
(define (read-test1)
(with-input-from-file
rnd.txt
(lambda ()
(let lp ((i (read)))
(if (not (eof-object? i))
(lp (read)))
scheme@(guile-user) ,time
Andy Wingo wi...@pobox.com skribis:
I just took a look at your program, which ran in 40s on my machine.
Under callgrind it turned out that we were doing a lot of iconv stuff
that we didn't need to do.
It’s often the case that I/O is faster if you explicitly say that the
port is UTF-8-encoded,
It is way too slow to read numbers from a file simply by using `read'
for example a txt file contains 10,000,000 line of numbers:
(define (gen-sample max k file)
(with-output-to-file
file
(lambda ()
(let lp ((k k))
(when ( k 0)
(display
From: Darren Hoo darren@gmail.com
It is way too slow to read numbers from a file simply by using `read'
The problem mostly lies in dealing with the locale or doing utf-8
conversion. Also, your code creates and destroys a lot of strings.
You could push data through much more quickly if