Skip to content

Instantly share code, notes, and snippets.

@yamasushi
Last active December 18, 2015 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yamasushi/5719441 to your computer and use it in GitHub Desktop.
Save yamasushi/5719441 to your computer and use it in GitHub Desktop.
$ gosh memtest
#?="./memtest.scm":19:(gcstat-used-heap (gc-stat))
#?- 1191.936
#?="with-input-from-port"
#?- "with-input-from-port"
#?="./memtest.scm":24:(gcstat-used-heap (gc-stat))
#?- 26759.168
$ gosh memtest
#?="./memtest.scm":19:(gcstat-used-heap (gc-stat))
#?- 1187.84
#?="read-line only"
#?- "read-line only"
#?="./memtest.scm":24:(gcstat-used-heap (gc-stat))
#?- 25575.424
$ calc 26759.168 - 25575.424
1183.744
; memtest
(use srfi-1)
(define (gcstat-used-heap s)
(/ (- ($ car $ assoc-ref s :total-heap-size) ($ car $ assoc-ref s :free-bytes )) 1000.) )
(define (read-data reader fname)
(call-with-input-file fname
(^ [in] (port->list reader in) )
:encoding "Shift_JIS"
) )
(define (test-reader port) (with-input-from-port port (^[] (read-line) ) ) )
;(define (test-reader port) (with-input-from-port port (^[] (read-line port) ) ) )
(define fname "/home/shuji/gauche-data/csv/ken_all.csv")
(debug-print-width #f)
(gc) #?=(gcstat-used-heap (gc-stat))
;--------------------------------------
#?="read-line only" (read-data read-line fname)
;#?="with-input-from-port" (read-data test-reader fname)
;--------------------------------------
(gc) #?=(gcstat-used-heap (gc-stat))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment