Hello! Andy Wingo <wi...@pobox.com> skribis:
> On Sun 17 Apr 2016 12:44, l...@gnu.org (Ludovic Courtès) writes: > >> Andy Wingo <wi...@pobox.com> skribis: >> >>> I want to test four things. >>> >>> ;; 1. How long a loop up to 10 million takes (baseline measurement). >>> (let ((port (open-input-string "s"))) (do-times #e1e7 1)) >>> >>> ;; 2. A call to a simple Scheme function. >>> (define (foo port) 42) >>> (let ((port (open-input-string "s"))) (do-times #e1e7 (foo port))) >>> >>> ;; 3. A call to a port subr. >>> (let ((port (open-input-string "s"))) (do-times #e1e7 (port-line port))) >>> >>> ;; 4. A call to a port subr that touches the buffer. >>> (let ((port (open-input-string "s"))) (do-times #e1e7 (peek-char port))) >>> >>> The results: >>> >>> | baseline | foo | port-line | peek-char >>> ------------------+----------+--------+-----------+---------- >>> guile 2.0 | 0.269s | 0.845s | 1.067s | 1.280s >>> guile master | 0.058s | 0.224s | 0.225s | 0.433s >>> wip-port-refactor | 0.058s | 0.220s | 0.226s | 0.375s >> >> Oh, nice! (By “prohibitively slow” I was referring to 2.0.) >> >> For ‘peek-char’, isn’t there also the fact that string ports in 2.2 are >> UTF-8 by default, so we get the fast path, whereas in 2.0 there >> ‘%default-port-encoding’, which could be something else leading to the >> slow path? > > I tried making sure the string port was a UTF-8 port but that made no > difference to the 2.0 peek-char times. I suspect this is because I ran > it at the REPL, which had done a setlocale() already. But perhaps > that's not the right explanation. It’s definitely the case if you use a UTF-8 locale. Thanks for checking! Ludo’.