Last active
December 18, 2015 03:29
-
-
Save yamasushi/5718069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gosh -fcollect-stats csv/test-csv ken_all.csv | |
#?="/home/shuji/gauche/csv/test-csv.scm":47:(benchmark reader) | |
;(time (read-data rdr (cadr args))) | |
; real 8.046 | |
; user 7.540 | |
; sys 0.250 | |
#?="/home/shuji/gauche/csv/test-csv.scm":42:(gcstat-used-heap e) | |
#?- 113049.6 | |
#?- ((:total-heap-size 124317.69600000001) (:free-bytes 15593.472000000002) (:total-bytes 193734.06399999998)) | |
;; Statistics (*: main thread only): | |
;; GC: 128815104bytes heap, 201367328bytes allocated | |
;; stack overflow*: 0times, 0.00ms total/0.00ms avg | |
$ gosh -fcollect-stats csv/test-csv ken_all.csv | |
#?="/home/shuji/gauche/csv/test-csv.scm":48:(benchmark kaizou:reader) | |
;(time (read-data rdr (cadr args))) | |
; real 7.292 | |
; user 6.870 | |
; sys 0.300 | |
#?="/home/shuji/gauche/csv/test-csv.scm":42:(gcstat-used-heap e) | |
#?- 111206.4 | |
#?- ((:total-heap-size 107753.47200000001) (:free-bytes 876.544) (:total-bytes 160177.944)) | |
;; Statistics (*: main thread only): | |
;; GC: 112250880bytes heap, 167803752bytes allocated | |
;; stack overflow*: 0times, 0.00ms total/0.00ms avg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env gosh | |
;;; -*- mode: scheme; coding: utf-8 -*- | |
(use srfi-1) | |
(use text.csv) | |
(use csv.csv :prefix kaizou:) | |
(define sep #\,) | |
(define quo #\') | |
(define reader (make-csv-reader sep quo)) | |
(define kaizou:reader (kaizou:make-csv-reader sep quo)) | |
#| | |
(define line " ,,f oo ,\nbar,''' ,' ,,") | |
#?=(port->list reader (open-input-string line) ) | |
#?=(port->list kaizou:reader (open-input-string line) ) | |
(exit) | |
|# | |
;((:total-heap-size 128815104) (:free-bytes 13176832) (:bytes-since-gc 37375072) (:total-bytes 201361744)) | |
(define (gcstat-used-heap s) | |
(/ (- ($ car $ assoc-ref s :total-heap-size) ($ car $ assoc-ref s :free-bytes )) 1000.) ) | |
(define (diff-gcstat s e) | |
(define keys '(:total-heap-size :free-bytes :total-bytes ) ) | |
($ zip keys $ map (^k (- ($ (cut / <> 1000. ) $ car $ assoc-ref e k) ($ (cut / <> 1000. ) $ car $ assoc-ref s k) ) ) keys) ) | |
(define (main args) | |
(define (read-data reader fname) | |
(call-with-input-file fname | |
(^ [in] (port->list reader in) ) | |
:encoding "Shift_JIS") ) | |
(define (write-test fnam rdr) | |
(with-output-to-file fnam (^[] ($ for-each write $ read-data rdr (cadr args) ) ) ) ) | |
(define (benchmark rdr) | |
(let1 s (gc-stat) | |
(let1 x ($ time $ read-data rdr (cadr args) ) | |
(gc) | |
(let1 e (gc-stat) | |
#?=(gcstat-used-heap e) | |
(diff-gcstat s e) ) ) ) ) | |
;(with-output-to-file "csv-org.txt" (^[] ($ for-each write $ read-data reader (cadr args) ) ) ) | |
;(with-output-to-file "csv-test.txt" (^[] ($ for-each write $ read-data kaizou:reader (cadr args) ) ) ) | |
(debug-print-width #f) | |
;#?=(benchmark reader) | |
#?=(benchmark kaizou:reader) | |
0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment