A follow-up commit will remove the -cformatter flag entirely.
Formatting the generated C code is now a small fraction of where "wuffs
gen" spends its time.
----
$ # Before.
$ time wuffs gen > /dev/null
real 0m0.932s
user 0m0.837s
sys 0m0.187s
$ # After.
$ time wuffs gen > /dev/null
real 0m0.186s
user 0m0.170s
sys 0m0.069s
$ time wuffs gen -cformatter= > /dev/null
real 0m0.184s
user 0m0.170s
sys 0m0.059s
----
genrelease essentially concatenates the individual packages' generated C
files, which should already be formatted.
----
$ # Before.
$ time wuffs gen > /dev/null
real 0m2.622s
user 0m2.457s
sys 0m0.266s
$ # After.
$ time wuffs gen > /dev/null
real 0m1.433s
user 0m1.335s
sys 0m0.191s
----
Reinforcing the previous commit's (e5cc4a42) observation, over 93% of
compilation time (converting foo.wuffs into foo.c) is spent piping the
generated C code through clang-format.
----
$ time wuffs gen -cformatter=clang-format-5.0 > /dev/null
real 0m2.855s
user 0m2.680s
sys 0m0.286s
$ time wuffs gen -cformatter= > /dev/null
real 0m0.175s
user 0m0.172s
sys 0m0.050s
----
----
$ time wuffs gen
1 milliseconds generating the C code
753 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-base.c
0 milliseconds generating the C code
19 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-adler32.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/adler32.wuffs
1 milliseconds generating the C code
61 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-bmp.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/bmp.wuffs
1 milliseconds generating the C code
78 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-crc32.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/crc32.wuffs
2 milliseconds generating the C code
93 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-deflate.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/deflate.wuffs
0 milliseconds generating the C code
34 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-lzw.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/lzw.wuffs
4 milliseconds generating the C code
203 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-gif.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/gif.wuffs
0 milliseconds generating the C code
33 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-gzip.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/gzip.wuffs
4 milliseconds generating the C code
135 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-json.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/json.wuffs
0 milliseconds generating the C code
44 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-wbmp.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/wbmp.wuffs
0 milliseconds generating the C code
32 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-zlib.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/zlib.wuffs
3 milliseconds collecting the C code
1173 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/release/c/wuffs-unsupported-snapshot.c
real 0m2.849s
user 0m2.674s
sys 0m0.278s
----
As the cmd/ractool comment changes say, this is almost a 2x speed-up for
RAC+Zlib decoding on the enwik8 test file, comparable to the cgozlib
benchmark numbers:
$ go test -test.bench=. github.com/google/wuffs/lib/cgozlib
goos: linux
goarch: amd64
pkg: github.com/google/wuffs/lib/cgozlib
BenchmarkCgo-56 2514 477230 ns/op
BenchmarkPure-56 1090 1080853 ns/op