• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..06-Aug-2020-

examples/H06-Aug-2020-6753

README.mdH A D06-Aug-20203.5 KiB5745

base.goH A D06-Aug-2020253 118

cbor.goH A D06-Aug-20202.8 KiB10171

decode_stream.goH A D06-Aug-202014.8 KiB615539

decoder_test.goH A D06-Aug-20206.6 KiB206182

string.goH A D06-Aug-20201.7 KiB6953

string_test.goH A D06-Aug-20204.7 KiB119109

time.goH A D06-Aug-20202.5 KiB9477

time_test.goH A D06-Aug-20202.5 KiB10090

types.goH A D06-Aug-202013.6 KiB479392

types_64_test.goH A D06-Aug-2020750 3526

types_test.goH A D06-Aug-20208.1 KiB318286

README.md

1## Reference:
2   CBOR Encoding is described in [RFC7049](https://tools.ietf.org/html/rfc7049)
3
4## Comparison of JSON vs CBOR
5
6Two main areas of reduction are:
7
81. CPU usage to write a log msg
92. Size (in bytes) of log messages.
10
11
12CPU Usage savings are below:
13```
14name                                    JSON time/op    CBOR time/op   delta
15Info-32                                   15.3ns ± 1%    11.7ns ± 3%  -23.78%  (p=0.000 n=9+10)
16ContextFields-32                          16.2ns ± 2%    12.3ns ± 3%  -23.97%  (p=0.000 n=9+9)
17ContextAppend-32                          6.70ns ± 0%    6.20ns ± 0%   -7.44%  (p=0.000 n=9+9)
18LogFields-32                              66.4ns ± 0%    24.6ns ± 2%  -62.89%  (p=0.000 n=10+9)
19LogArrayObject-32                          911ns ±11%     768ns ± 6%  -15.64%  (p=0.000 n=10+10)
20LogFieldType/Floats-32                    70.3ns ± 2%    29.5ns ± 1%  -57.98%  (p=0.000 n=10+10)
21LogFieldType/Err-32                       14.0ns ± 3%    12.1ns ± 8%  -13.20%  (p=0.000 n=8+10)
22LogFieldType/Dur-32                       17.2ns ± 2%    13.1ns ± 1%  -24.27%  (p=0.000 n=10+9)
23LogFieldType/Object-32                    54.3ns ±11%    52.3ns ± 7%     ~     (p=0.239 n=10+10)
24LogFieldType/Ints-32                      20.3ns ± 2%    15.1ns ± 2%  -25.50%  (p=0.000 n=9+10)
25LogFieldType/Interfaces-32                 642ns ±11%     621ns ± 9%     ~     (p=0.118 n=10+10)
26LogFieldType/Interface(Objects)-32         635ns ±13%     632ns ± 9%     ~     (p=0.592 n=10+10)
27LogFieldType/Times-32                      294ns ± 0%      27ns ± 1%  -90.71%  (p=0.000 n=10+9)
28LogFieldType/Durs-32                       121ns ± 0%      33ns ± 2%  -72.44%  (p=0.000 n=9+9)
29LogFieldType/Interface(Object)-32         56.6ns ± 8%    52.3ns ± 8%   -7.54%  (p=0.007 n=10+10)
30LogFieldType/Errs-32                      17.8ns ± 3%    16.1ns ± 2%   -9.71%  (p=0.000 n=10+9)
31LogFieldType/Time-32                      40.5ns ± 1%    12.7ns ± 6%  -68.66%  (p=0.000 n=8+9)
32LogFieldType/Bool-32                      12.0ns ± 5%    10.2ns ± 2%  -15.18%  (p=0.000 n=10+8)
33LogFieldType/Bools-32                     17.2ns ± 2%    12.6ns ± 4%  -26.63%  (p=0.000 n=10+10)
34LogFieldType/Int-32                       12.3ns ± 2%    11.2ns ± 4%   -9.27%  (p=0.000 n=9+10)
35LogFieldType/Float-32                     16.7ns ± 1%    12.6ns ± 2%  -24.42%  (p=0.000 n=7+9)
36LogFieldType/Str-32                       12.7ns ± 7%    11.3ns ± 7%  -10.88%  (p=0.000 n=10+9)
37LogFieldType/Strs-32                      20.3ns ± 3%    18.2ns ± 3%  -10.25%  (p=0.000 n=9+10)
38LogFieldType/Interface-32                  183ns ±12%     175ns ± 9%     ~     (p=0.078 n=10+10)
39```
40
41Log message size savings is greatly dependent on the number and type of fields in the log message.
42Assuming this log message (with an Integer, timestamp and string, in addition to level).
43
44`{"level":"error","Fault":41650,"time":"2018-04-01T15:18:19-07:00","message":"Some Message"}`
45
46Two measurements were done for the log file sizes - one without any compression, second
47using [compress/zlib](https://golang.org/pkg/compress/zlib/).
48
49Results for 10,000 log messages:
50
51| Log Format |  Plain File Size (in KB) | Compressed File Size (in KB) |
52| :--- | :---: | :---: |
53| JSON | 920 | 28 |
54| CBOR | 550 | 28 |
55
56The example used to calculate the above data is available in [Examples](examples).
57