Efficiency of gob mapping

182 views
Skip to first unread message

bsr

unread,
Jul 18, 2012, 9:55:38 AM7/18/12
to golan...@googlegroups.com
Hello,

I use code similar to 


for mapping and persisting complex structure to database.

How inefficient is it? I am not sure anyway to optimize (not sure reuse buffer etc make difference or cause any issue). Please give any suggestion to improve it.

thanks

John Asmuth

unread,
Jul 18, 2012, 10:00:21 AM7/18/12
to golan...@googlegroups.com
Encoding to gob is faster than writing it to a disk, so you probably don't need to worry about it.

rif

unread,
Jul 18, 2012, 10:55:02 AM7/18/12
to golan...@googlegroups.com
For me it was to slow (it is better to be used with larger streams of data). I ended up writing my own encoder/decoder for my structures.

Rob Pike

unread,
Jul 18, 2012, 11:27:16 AM7/18/12
to rif, golan...@googlegroups.com
The gob package does a lot of work the first time it sees a type to
encode/decode on a given encoder/decoder. In effect, it builds a
little JIT. Once that's built it's reasonably efficient if there's
lots of data, but there is a modest constant-time overhead. Your
example contains nothing to encode (the structs are empty) so it's not
a realistic example upon which to base any decision about performance.

-rob
Reply all
Reply to author
Forward
0 new messages