Commit Graph

4 Commits

Author SHA1 Message Date
Josh Baker f8aa7a1962 Optimistically expect simple strings for json (#6)
Performance update to appendJSONString so that it now checks if
the input is a simple string that contains no json delimiters, control
characters, or unicode. If simple then the operation is only three
appends. [double-quote, string, double-quote].

If a non-simple character is encountered then all of the previous
characters are appended and the operation falls back to the original
method for the remaining characters.

Before:

  BenchmarkLogEmpty-8	    100000000	        17.1 ns/op
  BenchmarkDisabled-8	    500000000	         4.12 ns/op
  BenchmarkInfo-8		    20000000	       101 ns/op
  BenchmarkContextFields-8    20000000	       105 ns/op
  BenchmarkLogFields-8	     5000000	       281 ns/op

After:

  BenchmarkLogEmpty-8	    100000000	        16.7 ns/op
  BenchmarkDisabled-8	    500000000	         3.79 ns/op
  BenchmarkInfo-8		    30000000	        44.8 ns/op
  BenchmarkContextFields-8    30000000	        67.5 ns/op
  BenchmarkLogFields-8	    10000000	       197 ns/op
2017-06-23 20:28:33 -07:00
Olivier Poitrey fa2d76dd80 Add some test 2017-05-19 21:57:46 -07:00
Olivier Poitrey d0cfcbbafe Write directly into a single shared buffer per event for even better perf 2017-05-19 19:45:46 -07:00
Olivier Poitrey 7f302b00ec Initial commit 2017-05-13 16:22:35 -07:00