Re: How to read integers from file faster?

2013-09-02 Thread Pascal J. Bourguignon
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

Re: How to read integers from file faster?

2013-09-02 Thread Daniel Llorens
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:

Re: How to read integers from file faster?

2013-09-01 Thread Andy Wingo
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

Re: How to read integers from file faster?

2013-09-01 Thread Ludovic Courtès
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

Re: How to read integers from file faster?

2013-08-31 Thread Mark H Weaver
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

Re: How to read integers from file faster?

2013-08-31 Thread Andy Wingo
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

Re: How to read integers from file faster?

2013-08-31 Thread Ludovic Courtès
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,

How to read integers from file faster?

2013-08-30 Thread Darren Hoo
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

Re: How to read integers from file faster?

2013-08-30 Thread Mike Gran
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