XANi/uberstatus

Research migrating plugin output format to "text/template"

Closed this issue · 2 comments

XANi commented

Pros: ability to have pretty formatting strings like Mem: {{.MemoryUsed}}; also with freeform numeric formatting: CPU:{{printf "%05.2f" .Load}}

Cons: it is about 7x as slow:

BenchmarkFmt-4          	 3000000	       503 ns/op
BenchmarkFmtLong-4      	  500000	      3606 ns/op
BenchmarkTpl-4          	  500000	      3740 ns/op
BenchmarkTplLong-4      	   50000	     26668 ns/op

Altho that even for something ran few times a second is probably a small impact

mkf commented

Me under #8:

Rewriting plugins using text/template takes time, and would be done in a separate branch for some time, so I think this PR could be merged for now. Regarding text/template, are you sure it's strings would be intuitive enough for everyone? Also, does it need to be somewhat like an interface for every plugin to support text/template? Memory plugin wouldn't benefit from it that much IMHO. Weather and battery plugins would indeed though.

XANi commented

Helper classes added to uberstatus/util #7197a2c; plugins that made sense to use that rewritten