1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;;; Free Software published under an MIT-like license. See LICENSE ;;;
5 ;;; Copyright (c) 2012 Google, Inc. All rights reserved. ;;;
7 ;;; Original author: Scott McKay ;;;
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11 (in-package "PROTO-TEST")
14 ;;; (De)serializing of 1 meg of geodata for metering purposes
16 (defvar *geowd* #.(make-pathname
17 :directory (pathname-directory
18 (or *compile-file-truename* *load-truename*))))
20 (defvar *geo-file-name* (merge-pathnames "geodata.data" *geowd*))
22 (defun deserialize-geo-file ()
23 (proto:deserialize-object-from-file 'geodata::geodata *geo-file-name*))
25 (defun serialize-geo-data (geodata)
26 (proto:serialize-object-to-bytes geodata 'geodata::geodata))
28 (defun deserialize-geo-data (bytes)
29 (proto:deserialize-object 'geodata::geodata bytes))
32 ;; How long does it take to load (deserialize) the data, unoptimized?
33 ;; On my 2011-ish Linux desktop,
34 ;; - about 10-11 Mbyte/sec using SBCL
35 ;; - about 3- 4 Mbyte/sec using CCL
36 (time (setq *geo* (deserialize-geo-file)))
38 ;; How long does it take to serialize, unoptimized?
39 ;; On my 2011-ish Linux desktop,
40 ;; - about 7-8 Mbyte/sec using SBCL
41 ;; - about 5-6 Mbyte/sec using CCL
42 (time (progn (serialize-geo-data *geo*) nil))
44 ;; Optimize the (de)serializers
45 (dolist (class '(geodata:country
53 geodata:country-currencies
55 geodata:geodata geodata:geodata-v))
56 (let ((message (proto:find-message geodata::*geodata* class)))
57 (eval (proto-impl:generate-object-size message))
58 (eval (proto-impl:generate-serializer message))
59 (eval (proto-impl:generate-deserializer message))))
61 ;; Now how long does it take to load (deserialize) the data, optimized?
62 ;; On my 2011-ish Linux desktop,
63 ;; - about 20-25 Mbyte/sec using SBCL
64 ;; - about 5- 6 Mbyte/sec using CCL
65 (time (setq *geo* (deserialize-geo-file)))
67 ;; How long does it take to serialize, optimized?
68 ;; On my 2011-ish Linux desktop,
69 ;; - about 20-25 Mbyte/sec using SBCL
70 ;; - about 7- 8 Mbyte/sec using CCL
71 (time (progn (serialize-geo-data *geo*) nil))