Skip to content

Instantly share code, notes, and snippets.

Avatar

Shiro Kawai shirok

View GitHub Profile
View gist:7008dbe09942a35df7a75dadd3c05a61
diff --git a/sanmai.scm b/sanmai.scm
index 5fcc936..773fbaf 100644
--- a/sanmai.scm
+++ b/sanmai.scm
@@ -58,7 +58,7 @@
(de FRAME-RATE 44100)
(de FADE-MS 3)
-(de FRAME/MS (/ FRAME-RATE 1000))
+(de FRAME/MS (/. FRAME-RATE 1000))
View gist:191e7f7c85a43a8b9c2cc594b7a6d0f5
Profiler statistics (total 49765 samples, 497.65000000000003 seconds)
num time/ total
Name calls call(ms) samples
---------------------------------------------------+------+-------+-----------
(step! <env-adsr>) 52920000 0.0016 8512( 17%)
(set-stereo! <stereo-holder> <real> <real>) 55566000 0.0015 8338( 17%)
(step! <single-osc>) 26460000 0.0025 6672( 13%)
(step! <dual-osc>) 13230000 0.0049 6432( 13%)
(next-state! <env>) 52920000 0.0009 4942( 10%)
(step! <channel>) 13230000 0.0028 3769( 8%)
View f.scm
(dotimes [n 101]
((lambda args
(newline) ; ~&, should be fresh-line
(let/cc break
(case (car args) ; ~[
[(0)] ; ~;
[(1) (display (cadr args)) ; ~A
(if (zero? (caddr args)) (break))] ; ~v^, ~;
[(2)] ; ~;
[(3) (display "Fi")] ; Fi~;
View cxr2.lisp
(defun expand-cxr (ads)
(labels ((expand (ads)
(cond
((null ads) 'x)
((equalp (car ads) #\a) `(cl:car ,(expand (cdr ads))))
(t `(cl:cdr ,(expand (cdr ads)))))))
(let* ((nam (coerce `(#\c ,@ads #\r) 'string))
(sym (intern (ecase (readtable-case *cxr-readtable*)
((:upcase) (string-upcase nam))
((:downcase) (string-downcase nam))
View cxr.lisp
(defvar *original-readtable* *readtable*)
(defvar *cxr-readtable* (copy-readtable *original-readtable*))
(defconstant +constituents+
(remove-if #'get-macro-character
"!$%&0123456789<=>?[]^_{}~.+-*/@ABCDEFGHIJKLMNOPQRTSUVWXYZabcdefghijklmnopqrstuvwxyz"))
(defun cxr-reader (stream char)
(let* ((chars (loop with cs = `(,char)
for c = (peek-char nil stream nil nil t)
View gumowski-mira.html
<html>
<body>
<form action="#">
α: <input type="text" id="α" value="0.008"/>
σ: <input type="text" id="σ" value="0.05"/>
μ: <input type="text" id="μ" value="-0.496"/>
<button type="button" onclick="plot()">redraw</button>
</form>
<canvas id="canvas" width="1000" height="1000"></canvas>
View t.scm
Benchmark: ran giterate0, giterate0-1, giterate0-2, giterate0-3, giterate1, giterate1-1, giterate1-2, giterate2, each for 10 times.
giterate0: 6.322 real, 6.310 cpu (6.300 user + 0.010 sys)@1.58/s n=10
giterate0-1: 6.336 real, 6.320 cpu (6.320 user + 0.000 sys)@1.58/s n=10
giterate0-2: 6.583 real, 6.560 cpu (6.560 user + 0.000 sys)@1.52/s n=10
giterate0-3: 6.538 real, 6.520 cpu (6.520 user + 0.000 sys)@1.53/s n=10
giterate1: 7.110 real, 7.110 cpu (7.110 user + 0.000 sys)@1.41/s n=10
giterate1-1: 7.004 real, 7.010 cpu (7.010 user + 0.000 sys)@1.43/s n=10
giterate1-2: 6.564 real, 6.560 cpu (6.560 user + 0.000 sys)@1.52/s n=10
giterate2: 5.977 real, 5.980 cpu (5.980 user + 0.000 sys)@1.67/s n=10
View t.scm
Benchmark: ran giterate0, giterate0-1, giterate0-2, giterate1, giterate1-1, giterate2, each for 10 times.
giterate0: 14.390 real, 21.430 cpu (21.250 user + 0.180 sys)@0.47/s n=10
giterate0-1: 6.278 real, 6.270 cpu ( 6.270 user + 0.000 sys)@1.59/s n=10
giterate0-2: 6.561 real, 6.560 cpu ( 6.560 user + 0.000 sys)@1.52/s n=10
giterate1: 7.057 real, 7.050 cpu ( 7.050 user + 0.000 sys)@1.42/s n=10
giterate1-1: 6.960 real, 6.960 cpu ( 6.960 user + 0.000 sys)@1.44/s n=10
giterate2: 5.934 real, 5.930 cpu ( 5.930 user + 0.000 sys)@1.69/s n=10
Rate giterate0 giterate0-1 giterate0-2 giterate1 giterate1-1 giterate2
giterate0 0/s -- 0.293 0.306 0.329 0.325 0.277
View t.scm
$ ./gosh -ftest ./t
Benchmark: ran giterate0, giterate0-1, giterate1, giterate2, gunfold1, each for 10 times.
giterate0: 14.336 real, 21.140 cpu (20.990 user + 0.150 sys)@0.47/s n=10
giterate0-1: 6.291 real, 6.290 cpu ( 6.290 user + 0.000 sys)@1.59/s n=10
giterate1: 7.002 real, 7.000 cpu ( 7.000 user + 0.000 sys)@1.43/s n=10
giterate2: 5.903 real, 5.910 cpu ( 5.910 user + 0.000 sys)@1.69/s n=10
gunfold1: 14.704 real, 14.720 cpu (14.710 user + 0.010 sys)@0.68/s n=10
Rate giterate0 giterate0-1 giterate1 giterate2 gunfold1
giterate0 0/s -- 0.298 0.331 0.280 0.696
View gist:be818e9be5a4a791d3855be3f28061f8
gosh> (let ((cs '()))
(dolist (x '(1 2 3 4 5))
(push! cs (lambda () x)))
(map (lambda (c) (c)) cs))
(5 4 3 2 1)
gosh> (let ((cs '()))
(do ((xs '(1 2 3 4 5) (cdr xs)))
((null? xs))
(push! cs (lambda () (car xs))))
(map (lambda (c) (c)) cs))