2016-12-15-01-ひとまず大丈夫みたい
>> Site top >> weblog >> 月別アーカイブ >> 2016年12月のlog >> 2016-12-15-01-ひとまず大丈夫みたい
最終更新日付:2016/12/15 01:00:00
ひとまず大丈夫みたい
2016 年 12 月 15 日
修正前後の比較をしてみた。一応期待(というか予想)の通りだったと言えそうな感じ。
乱暴だけど、やったのは time でくるんだコードを15回くらい実行して、得られた値の中央値を取るというもの。これを修正前前後の両方でやり、比率を出した。まずは pair のオブジェクトをパラメータなしで作成するのをひたすら繰り返した。
;; default constructor of stl:pair (time (dotimes (x 1000000) (new stl:pair)))
結果は以下の通り。時間も空間も大体 1.5倍だねぇ。
processor cycles | bytes consed | |
---|---|---|
before | 84,981,007 | 63,999,472 |
after | 132,860,365 | 96,010,224 |
ratio | 1.5634124 | 1.5001721 |
他のアロケート系のやつを全部並べてしまおう。それ。
;; copy constructor of stl:pair (let ((pr (stl:make_pair 10 20))) (time (dotimes (x 1000000) (new stl:pair pr))))
processor cycles | bytes consed | |
---|---|---|
before | 230,762,642 | 64,032,096 |
after | 243,067,992 | 95,997,808 |
ratio | 1.0533247 | 1.4992139 |
;; cloning of stl:pair (let ((pr (stl:make_pair 10 20))) (time (dotimes (x 1000000) (clone pr))))
processor cycles | bytes consed | |
---|---|---|
before | 238,010,642 | 63,995,840 |
after | 239,728,012 | 95,998,928 |
ratio | 1.0072155 | 1.5000807 |
;; stl:make_pair (time (dotimes (x 1000000) (stl:make_pair x (1+ x))))
processor cycles | bytes consed | |
---|---|---|
before | 179,075,855 | 63,995888 |
after | 221,082,200 | 96,004128 |
ratio | 1.2345729 | 1.5001609 |
ここまででわかることは、時間にはバラ付きがあるものの、空間的にはほぼきっかり1.5倍になるみたいだということだ。ではアクセスはどうだろう。面倒なので、試したのを全部並べてしまおう。それ、どん。
;; stl:first / stl:second (let ((pr (stl:make_pair 10 20))) (time (dotimes (x 1000000) (stl:first pr) (stl:second pr))))
processor cycles | bytes consed | |
---|---|---|
before | 43,189,202 | 0 |
after | 32,877,128 | 0 |
ratio | 0.7612349 | ---- |
;; stl:get for pair (let ((pr (stl:make_pair 10 20))) (time (dotimes (x 1000000) (stl:get 0 pr) (stl:get 1 pr))))
processor cycles | bytes consed | |
---|---|---|
before | 116,212,944 | 0 |
after | 36,815,423 | 0 |
ratio | 0.3167928 | ---- |
;; stl:get for tuple (let ((tpl (stl:make_tuple 10 20 30))) (time (dotimes (x 1000000) (stl:get 0 tpl) (stl:get 1 tpl) (stl:get 2 tpl))))
processor cycles | bytes consed | |
---|---|---|
before | 296,089,075 | 0 |
after | 156,189,939 | 0 |
ratio | 0.52751 | ---- |
;; stl:get for stl:array (let ((arr (new stl:array 4 #{10 20 30}))) (time (dotimes (x 1000000) (stl:get 0 arr) (stl:get 1 arr) (stl:get 2 arr))))
processor cycles | bytes consed | |
---|---|---|
before | 261,042,587 | 0 |
after | 114,963,291 | 0 |
ratio | 0.4404005 | ---- |
;; stl:tie for pair (let ((pr (stl:make_pair 10 20)) (v1 nil) (v2 nil)) (time (dotimes (x 1000000) (stl:tie (v1 v2) pr))))
processor cycles | bytes consed | |
---|---|---|
before | 198,309,011 | 0 |
after | 107,288,442 | 0 |
ratio | 0.54101646 | ---- |
;; stl:tie for tuple (let ((tpl (stl:make_tuple 10 20 30)) (v1 nil) (v2 nil) (v3 nil)) (time (dotimes (x 1000000) (stl:tie (v1 v2 v3) tpl))))
processor cycles | bytes consed | |
---|---|---|
before | 513,335,079 | 0 |
after | 200,097,461 | 0 |
ratio | 0.3897989 | ---- |
;; stl:with_tie for pair (let ((pr (stl:make_pair 10 20))) (time (dotimes (x 1000000) (stl:with_tie (v1 v2) pr (let ((tmp v1)) (setf v1 v2) (setf v2 tmp))))))
processor cycles | bytes consed | |
---|---|---|
before | 225,374,812 | 0 |
after | 23,733,804 | 0 |
ratio | 0.105308145 | ---- |
;; stl:with_tie for tuple (let ((tpl (stl:make_tuple 10 20 30))) (time (dotimes (x 1000000) (stl:with_tie (v1 v2 v3) tpl (let ((tmp v1)) (setf v1 v2) (setf v2 v3) (setf v3 tmp))))))
processor cycles | bytes consed | |
---|---|---|
before | 865,849,285 | 0 |
after | 27,973,682 | 0 |
ratio | 0.032307796 | ---- |
‥‥‥いいんではないだろうか? 特に with_tie に関しては清々しいほど早くなっている。もちろんこれが狙いだったとは言え、ここまで変わるとは正直思っていなかった。メモリ消費が 1.5倍というのは正直ひっかかるが、ここは思いきってやってしまおうと思う。
コメント
このページのタグ
Page tag : STLとその移植
Page tag : Common Lisp
Copyright(C) 2005-2021 project-enigma.
Generated by CL-PREFAB.