-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_template_registry.txt
More file actions
38 lines (37 loc) · 1.03 KB
/
test_template_registry.txt
File metadata and controls
38 lines (37 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <chrono>
#include <thread>
#include "statshouse.hpp"
int main() {
statshouse::Registry t;
for (int i=0; i<{{.NumberOfIterations}}; ++i) {
{{- range $v := .Metrics }}
{
{{- if eq $v.Kind 2 -}}
uint64_t a[{{ len $v.Uniques }}]={
{{- range $i, $v := $v.Uniques -}}
{{ if $i }},{{ end }}{{ $v }}
{{- end -}}
};
{{- else if eq $v.Kind 1 -}}
double a[{{ len $v.Values }}]={
{{- range $i, $v := $v.Values -}}
{{ if $i }},{{ end }}{{ $v }}
{{- end -}}
};
{{- end -}}
t.metric("{{ $v.Name }}")
{{- range $v := $v.Tags -}}
.tag("{{ index $v 0 }}","{{ index $v 1 }}")
{{- end -}}
{{- if eq $v.Kind 2 -}}
.write_unique(a,{{ len $v.Uniques }},{{ printf "%.1f" $v.Count }},{{ $v.Timestamp }});
{{- else if eq $v.Kind 1 -}}
.write_values(a,{{ len $v.Values }},{{ printf "%.1f" $v.Count }},{{ $v.Timestamp }});
{{- else -}}
.write_count({{ printf "%.1f" $v.Count }},{{ $v.Timestamp }});
{{- end -}}
}
{{- end }}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}