]> asedeno.scripts.mit.edu Git - cl-protobufs.git/blob - tests/geodata.lisp
integer encoding/decoding tests
[cl-protobufs.git] / tests / geodata.lisp
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;;;                                                                  ;;;
3 ;;; Free Software published under an MIT-like license. See LICENSE   ;;;
4 ;;;                                                                  ;;;
5 ;;; Copyright (c) 2012 Google, Inc.  All rights reserved.            ;;;
6 ;;;                                                                  ;;;
7 ;;; Original author: Scott McKay                                     ;;;
8 ;;;                                                                  ;;;
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10
11 (in-package "PROTO-TEST")
12
13
14 ;;; (De)serializing of 1 meg of geodata for metering purposes
15
16 (defvar *geowd* #.(make-pathname
17                    :directory (pathname-directory
18                                (or *compile-file-truename* *load-truename*))))
19
20 (defvar *geo-file-name* (merge-pathnames "geodata.data" *geowd*))
21
22 (defun deserialize-geo-file ()
23   (proto:deserialize-object-from-file 'geodata::geodata *geo-file-name*))
24
25 (defun serialize-geo-data (geodata)
26   (proto:serialize-object-to-bytes geodata 'geodata::geodata))
27
28 (defun deserialize-geo-data (bytes)
29   (proto:deserialize-object 'geodata::geodata bytes))
30
31 #||
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)))
37
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))
43
44 ;; Optimize the (de)serializers
45 (dolist (class '(geodata:country
46                  geodata:region
47                  geodata:region-key
48                  geodata:city
49                  geodata:airport
50                  geodata:timezone
51                  geodata:tz-variation
52                  geodata:currency
53                  geodata:country-currencies
54                  geodata:carrier
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))))
60
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)))
66
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))
72 ||#