Created
August 4, 2010 05:20
-
-
Save miyamuko/507687 to your computer and use it in GitHub Desktop.
xl-json: バイトコンパイルあり・なしでのjsonのベンチマーク
This file contains hidden or 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
| ;; バイトコンパイルあり・なしでのjsonのベンチマーク | |
| (require "json") | |
| (require "xml-http-request") | |
| (defmacro benchmark (&body body) | |
| `(let (times result) | |
| (dotimes (i 4) | |
| (gc t) | |
| (message "~[Warm up~:;Round ~:*~A~]" i) | |
| (let ((s (get-internal-real-time)) | |
| (r (progn ,@body)) | |
| (e (get-internal-real-time))) | |
| (unless (zerop i) | |
| (push (/ (- e s) 1000.0) times) | |
| (setf result r)))) | |
| (message "done") | |
| (values times (/ (apply '+ times) (length times)) | |
| result))) | |
| (let* ((url "http://www.google.co.jp/") | |
| (hatebu-url (concat "http://b.hatena.ne.jp/entry/json/" url)) | |
| (text (xhr:xhr-get hatebu-url :key 'xhr:xhr-response-text))) | |
| (benchmark | |
| (json:json-decode text))) | |
| ;; バイトコンパイルなし | |
| (43.484 45.578 45.735) | |
| 44.93233 | |
| ;; バイトコンパイルあり | |
| (0.64 0.656 0.578) | |
| 0.6246667 | |
| ;; バイトコンパイルすると約 72 倍早い | |
| (/ 44.93233 0.6246667) | |
| 71.93009 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment