Re: [Chicken-users] git rm write-line?
* Sascha Ziemann cev...@gmail.com [110921 10:11]: What the hell does write-line do? I used this script: #! /usr/local/bin/csi -s (define (write-line* line) (display line) (newline)) (if (not (null? (command-line-arguments))) (set! write-line write-line*)) (let next-line ((line (read-line))) (if (not (eof-object? line)) (begin (write-line line) (next-line (read-line) The build in write-line: $ dd if=/dev/zero bs=1M count=100 | od -xv | cat.scm /dev/null 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 18.7047 s, 5.6 MB/s The self written version: $ dd if=/dev/zero bs=1M count=100 | od -xv | cat.scm 1 /dev/null 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 13.3583 s, 7.8 MB/s Did you also switch off line buffering on the port? Maybe that's what's holding you up there for some reason? Just a guess though... -- Who can (make) the muddy water (clear)? Let it be still, and it will gradually become clear. Who can secure the condition of rest? Let movement go on, and the condition of rest will gradually arise. -- Lao Tse. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] git rm write-line?
On a second thought, here is what write-line does: (define write-line (lambda (str . port) (let ((p (if (##core#inline C_eqp port '()) ##sys#standard-output (##sys#slot port 0) ) ) ) (##sys#check-port p 'write-line) (##sys#check-string str 'write-line) (display str p) (newline p) ) ) ) and here is display: (define (display x #!optional (port ##sys#standard-output)) (##sys#check-port* port 'display) (##sys#print x #f port) ) And check-string: (define (##sys#check-string x . loc) (if (pair? loc) (##core#inline C_i_check_string_2 x (car loc)) (##core#inline C_i_check_string x) ) ) Now if you would uncomment the check-string in write-line, is it equally fast then? I would expect it to be. Then the question is, what makes check-string slower... Thanks, this is getting interesting! Christian -- Who can (make) the muddy water (clear)? Let it be still, and it will gradually become clear. Who can secure the condition of rest? Let movement go on, and the condition of rest will gradually arise. -- Lao Tse. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] git rm write-line?
2011/9/21 Christian Kellermann ck...@pestilenz.org: On a second thought, here is what write-line does: (define write-line (lambda (str . port) (let ((p (if (##core#inline C_eqp port '()) ##sys#standard-output (##sys#slot port 0) ) ) ) (##sys#check-port p 'write-line) (##sys#check-string str 'write-line) (display str p) (newline p) ) ) ) Ah I see. write-line is only a quick hack. I thought it would do something fast like fwrite. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] git rm write-line?
* Sascha Ziemann cev...@gmail.com [110921 10:33]: 2011/9/21 Christian Kellermann ck...@pestilenz.org: On a second thought, here is what write-line does: (define write-line (lambda (str . port) (let ((p (if (##core#inline C_eqp port '()) ##sys#standard-output (##sys#slot port 0) ) ) ) (##sys#check-port p 'write-line) (##sys#check-string str 'write-line) (display str p) (newline p) ) ) ) Ah I see. write-line is only a quick hack. I thought it would do something fast like fwrite. Well, now the choice is manyfold. One can whine about the slowness or improve the current situation or something completely different like shopping... I prefer improvement. Either way thanks for the nice test case, let's see if we can speed up thing in a way that makes it nicer. I am not sure why we check the string here, or why we check the port for being a port, since display will do it all over again. Can someone enlighten me on this? Kind regards, Christian -- Who can (make) the muddy water (clear)? Let it be still, and it will gradually become clear. Who can secure the condition of rest? Let movement go on, and the condition of rest will gradually arise. -- Lao Tse. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] git rm write-line?
On Wed, Sep 21, 2011 at 10:37:51AM +0200, Christian Kellermann wrote: Well, now the choice is manyfold. One can whine about the slowness or improve the current situation or something completely different like shopping... I prefer improvement. Who doesn't? Either way thanks for the nice test case, let's see if we can speed up thing in a way that makes it nicer. I am not sure why we check the string here, or why we check the port for being a port, since display will do it all over again. Can someone enlighten me on this? Probably for the (kind of lame) reason that the error location would otherwise show display, which the user never called. This could be solved by using an internal ##sys#display or something which gets called by both display and write-line, with the correct location. The scrutinizer could probably rewrite this not to use the check at all and call the underlying unsafe displaying routine directly. Cheers, Peter -- http://sjamaan.ath.cx -- The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music. -- Donald Knuth ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] git rm write-line?
2011/9/21 Christian Kellermann ck...@pestilenz.org: I prefer improvement. Btw this is what Bigloo does. Interpreted: $ dd if=/dev/zero bs=1M count=100 | od -xv | bigloo -i cat.scm /dev/null 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 10.6036 s, 9.9 MB/s Compiled with -static-all-bigloo: $ dd if=/dev/zero bs=1M count=100 | od -xv | ./a.out /dev/null 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 8.07031 s, 13.0 MB/s This is almost perfect compared to cat: $ dd if=/dev/zero bs=1M count=100 | od -xv | cat /dev/null 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 7.61719 s, 13.8 MB/s ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] git rm write-line?
From: Christian Kellermann ck...@pestilenz.org Subject: Re: [Chicken-users] git rm write-line? Date: Wed, 21 Sep 2011 10:37:51 +0200 * Sascha Ziemann cev...@gmail.com [110921 10:33]: 2011/9/21 Christian Kellermann ck...@pestilenz.org: On a second thought, here is what write-line does: (define write-line (lambda (str . port) (let ((p (if (##core#inline C_eqp port '()) ##sys#standard-output (##sys#slot port 0) ) ) ) (##sys#check-port p 'write-line) (##sys#check-string str 'write-line) (display str p) (newline p) ) ) ) Ah I see. write-line is only a quick hack. I thought it would do something fast like fwrite. Well, now the choice is manyfold. One can whine about the slowness or improve the current situation or something completely different like shopping... I prefer improvement. Either way thanks for the nice test case, let's see if we can speed up thing in a way that makes it nicer. I am not sure why we check the string here, or why we check the port for being a port, since display will do it all over again. Can someone enlighten me on this? It is intended to provide a more useful error message. Strange that this calls display. It could directly invoke the write-string port method (slot #3). cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users