Skip to content

Instantly share code, notes, and snippets.

View nyuichi's full-sized avatar

Yuichi Nishiwaki nyuichi

View GitHub Profile
@nyuichi
nyuichi / gist:4259882
Created December 11, 2012 16:15
decompose-interference
STL> (DECOMPOSE-INTERFERENCE dat)
seconds | gc | consed | calls | sec/call | name
------------------------------------------------------------
0.678 | 0.154 | 43,985,008 | 149,492 | 0.000005 | CREATE-VECTOR3
0.426 | 0.000 | 2,784,688 | 63,762 | 0.000007 | MAKE-SEGMENT
0.236 | 0.000 | 0 | 913,016 | 0.000000 | VECTOR3->VALUES
0.072 | 0.000 | 0 | 913,016 | 0.000000 | GET-X
0.022 | 0.000 | 0 | 174,211 | 0.000000 | PVDOT
0.017 | 0.000 | 949,856 | 21,254 | 0.000001 | GET-SEGMENTS
0.012 | 0.000 | 622,256 | 1,246 | 0.000009 | GET-NEIGHBOR-POINTS
@nyuichi
nyuichi / gist:4260014
Created December 11, 2012 16:25
no consing
STL> (DECOMPOSE-INTERFERENCE dat)
seconds | gc | consed | calls | sec/call | name
------------------------------------------------------------
0.381 | 0.000 | 2,981,200 | 63,762 | 0.000006 | MAKE-SEGMENT
0.338 | 0.000 | 0 | 913,016 | 0.000000 | VECTOR3->VALUES
0.181 | 0.000 | 35,158,896 | 149,492 | 0.000001 | CREATE-VECTOR3
0.112 | 0.000 | 0 | 913,016 | 0.000000 | GET-X
0.030 | 0.000 | 0 | 456,508 | 0.000000 | PV-
0.020 | 0.000 | 1,244,624 | 21,254 | 0.000001 | GET-SEGMENTS
0.015 | 0.000 | 0 | 913,016 | 0.000000 | GET-Z
@nyuichi
nyuichi / gist:4265732
Created December 12, 2012 07:11
vector3-optima 08bd068
STL> (DECOMPOSE-INTERFERENCE dat)
seconds | gc | consed | calls | sec/call | name
------------------------------------------------------------
0.170 | 0.000 | 1,964,640 | 63,762 | 0.000003 | MAKE-SEGMENT
0.059 | 0.051 | 94,547,952 | 2,954,795 | 0.000000 | MAKE-VECTOR3
0.059 | 0.000 | 0 | 108,780 | 0.000001 | POINT-IS-ON-SEGMENT-P
0.004 | 0.000 | 65,472 | 1,318 | 0.000003 | CATEGORIZE-POINT
0.002 | 0.000 | 32,752 | 1,318 | 0.000002 | GET-NEAREST-POINT
0.002 | 0.000 | 98,272 | 1,236 | 0.000001 | MIN/KEY
0.002 | 0.000 | 327,600 | 1,318 | 0.000001 | GET-NEIGHBOR-POINTS
@nyuichi
nyuichi / master 7b8cf42
Created December 12, 2012 11:10
profile decompose-interference
STL> (decompose-interference dat)
seconds | gc | consed | calls | sec/call | name
---------------------------------------------------------
0.010 | 0.000 | 1,375,520 | 4,034 | 0.000002 | GET-NEAREST-NEIGHBOR
0.005 | 0.000 | 98,304 | 17,712 | 0.000000 | GET-SEGMENT-SEGMENT-INTERSECTIONS
0.003 | 0.000 | 0 | 12,102 | 0.000000 | CATEGORIZE-FLOAT
0.002 | 0.000 | 0 | 13,052 | 0.000000 | POINT-IS-ON-TRIANGLE-EDGES-P
0.002 | 0.000 | 0 | 99 | 0.000022 | SPLIT-TRIANGLE
0.001 | 0.000 | 0 | 23,616 | 0.000000 | MAKE-SEGMENT
0.001 | 0.000 | 0 | 18,060 | 0.000000 | TAKE-A-VERTEX
@nyuichi
nyuichi / slime-repl-incremental-history-search.el
Created December 14, 2012 02:49
slime-repl-incremental-history-search
(defun slime-repl-incremental-history-search ()
(interactive)
(anything
(list
`((name . "slime history")
(candidates . ,slime-repl-input-history)
(action . (("Insert" . insert)))))))
(defstruct (vector-2d
(:constructor v2 (x y))
(:conc-name v2-))
x y)
(defun v2+ (v u)
(with-slots ((x1 x) (y1 y)) v
(with-slots ((x2 x) (y2 y)) u
(v2 (+ x1 x2) (+ y1 y2)))))
class Hoge {
static function hoge () : void {
(function () : void {
[1].forEach(function (_) { // fail to inline this function
Hoge.hoge();
});
})();
}
}
(defslime-repl-shortcut nil ("develop" "dev")
(:handler (lambda ()
(interactive)
(insert "(repl-utilities:dev " (slime-read-system-name) ")")
(slime-repl-send-input t)))
(:one-liner "Load and swap to system with repl-utilities stuff."))
(defslime-repl-shortcut nil ("bring")
(:handler (lambda ()
(interactive)
STL> (time (decompose-interference dat))
Evaluation took:
6.457 seconds of real time
5.456328 seconds of total run time (5.264858 user, 0.191470 system)
[ Run times consist of 0.458 seconds GC time, and 4.999 seconds non-GC time. ]
84.50% CPU
11,994,725,211 processor cycles
34 page faults
729,076,960 bytes consed
@nyuichi
nyuichi / example.lisp
Created January 9, 2013 17:27
C++-like template system for Common Lisp
(define-template-function add ((n) m)
(+ n m))
; (add (1) 2)
; => 3
; (add-1 3)
; => 4
(define-template-function lower-bound ((cmp key) value seq)