convertPrintable: add benchmarks, make readable, optimize.
This new version is less unreadable, 20x faster for ASCII, 7x faster for
ASCII with unprintables, and a little faster even for the slowest path of
valid non-ASCII.
Before:
```
--------------------------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------------------------
BM_log_convertPrintable_ascii 1228 ns 1228 ns 567338
BM_log_convertPrintable_non_printable 1399 ns 1399 ns 497617
BM_log_convertPrintable_non_ascii 6425 ns 6422 ns 107124
```
After:
```
BM_log_convertPrintable_ascii 53.3 ns 53.3 ns 13153971
BM_log_convertPrintable_non_printable 197 ns 197 ns 3555669
BM_log_convertPrintable_non_ascii 5490 ns 5488 ns 127360
```
Also build the benchmarks and fuzzer for the host.
Also improve the tests to cover the two corner cases that surprised me:
'\n' isn't escaped (I didn't think a log line could contain '\n', and it
seems like a bug to me if it can), and convertPrintable() returns a size
not including a terminating NUL but will always write a terminating NUL.
Bug: http://b/244624856
Test: treehugger
Change-Id: I903eb57fb867e50e70068707c18bbe7be2365fe8
6 files changed