|
| 1 | +#include <chrono> |
| 2 | +#include <thread> |
| 3 | +#include "statshouse.hpp" |
| 4 | + |
| 5 | +int main() { |
| 6 | + statshouse::TransportUDP t; |
| 7 | + for (int i=0; i<{{.NumberOfIterations}}; ++i) { |
| 8 | + {{- range $v := .Metrics }} |
| 9 | + { |
| 10 | + {{- if eq $v.Kind 2 -}} |
| 11 | + uint64_t a[{{ len $v.Uniques }}]={ |
| 12 | + {{- range $i, $v := $v.Uniques -}} |
| 13 | + {{ if $i }},{{ end }}{{ $v }} |
| 14 | + {{- end -}} |
| 15 | + }; |
| 16 | + {{- else if eq $v.Kind 1 -}} |
| 17 | + double a[{{ len $v.Values }}]={ |
| 18 | + {{- range $i, $v := $v.Values -}} |
| 19 | + {{ if $i }},{{ end }}{{ $v }} |
| 20 | + {{- end -}} |
| 21 | + }; |
| 22 | + {{- end -}} |
| 23 | + t.metric("{{ $v.Name }}") |
| 24 | + {{- range $v := $v.Tags -}} |
| 25 | + .tag("{{ index $v 0 }}","{{ index $v 1 }}") |
| 26 | + {{- end -}} |
| 27 | + {{- if eq $v.Kind 2 -}} |
| 28 | + .write_unique(a,{{ len $v.Uniques }},{{ printf "%.1f" $v.Count }},{{ $v.Timestamp }}); |
| 29 | + {{- else if eq $v.Kind 1 -}} |
| 30 | + .write_values(a,{{ len $v.Values }},{{ printf "%.1f" $v.Count }},{{ $v.Timestamp }}); |
| 31 | + {{- else -}} |
| 32 | + .write_count({{ printf "%.1f" $v.Count }},{{ $v.Timestamp }}); |
| 33 | + {{- end -}} |
| 34 | + } |
| 35 | + {{- end }} |
| 36 | + std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 37 | + } |
| 38 | +} |
0 commit comments