Skip to content

Commit 52873db

Browse files
committed
client test
1 parent ae964e8 commit 52873db

3 files changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ jobs:
1515
fetch-depth: 1
1616
install-go: false
1717
- run: g++ -std=c++11 -Wno-noexcept-type -g -Wall -Wextra -Werror=return-type --verbose statshouse_test.cpp
18+
statshouse-client-test:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 1
24+
- run: go run github.com/vkcom/statshouse/cmd/statshouse-client-test@master

test_template_registry.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <chrono>
2+
#include <thread>
3+
#include "statshouse.hpp"
4+
5+
int main() {
6+
statshouse::Registry 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+
}

test_template_transport.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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

Comments
 (0)