Skip to content

Commit 11ffa42

Browse files
committed
[add] kicking off examples. Making usage of go.mod
1 parent 65baaf7 commit 11ffa42

9 files changed

+685
-74
lines changed

.circleci/config.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ version: 2
55
jobs:
66
build: # test with circleci/golang:1.9
77
docker:
8-
- image: circleci/golang:1.9
8+
- image: circleci/golang:1.12
99

1010
working_directory: /go/src/github.com/filipecosta90/hdrhistogram
1111
steps:
1212
- checkout
13-
- run: go get -v -t -d ./...
14-
- run: go test -v ./. -race -coverprofile=coverage.txt -covermode=atomic
13+
- run: make test
1514
- run: bash <(curl -s https://codecov.io/bash) -t ${CODECOV_TOKEN}
1615

1716
workflows:

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.vscode/
22
.idea/
33

4+
coverage.txt
5+
46
# Binaries for programs and plugins
57
*.exe
68
*.exe~

.golangci.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# options for analysis running
2+
run:
3+
# include test files or not, default is true
4+
tests: false
5+
6+
linters-settings:
7+
golint:
8+
# minimal confidence for issues, default is 0.8
9+
min-confidence: 0.8
10+
11+
exclude-rules:
12+
# Exclude some linters from running on tests files.
13+
- path: _test\.go
14+
linters:
15+
- errcheck

Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Go parameters
2+
GOCMD=GO111MODULE=on go
3+
GOBUILD=$(GOCMD) build
4+
GOINSTALL=$(GOCMD) install
5+
GOCLEAN=$(GOCMD) clean
6+
GOTEST=$(GOCMD) test
7+
GOGET=$(GOCMD) get
8+
GOMOD=$(GOCMD) mod
9+
GOFMT=$(GOCMD) fmt
10+
11+
.PHONY: all test coverage
12+
all: test coverage
13+
14+
checkfmt:
15+
@echo 'Checking gofmt';\
16+
bash -c "diff -u <(echo -n) <(gofmt -d .)";\
17+
EXIT_CODE=$$?;\
18+
if [ "$$EXIT_CODE" -ne 0 ]; then \
19+
echo '$@: Go files must be formatted with gofmt'; \
20+
fi && \
21+
exit $$EXIT_CODE
22+
23+
lint:
24+
golangci-lint run
25+
26+
get:
27+
GO111MODULE=on $(GOGET) github.com/golangci/golangci-lint/cmd/golangci-lint
28+
$(GOGET) -t -v ./...
29+
30+
test: get lint
31+
$(GOFMT) ./...
32+
$(GOTEST) -race -covermode=atomic ./...
33+
34+
coverage: get test
35+
$(GOTEST) -race -coverprofile=coverage.txt -covermode=atomic .
36+

bench/bench_realtime_ops/bench_windowed_realtime_ops_test.go

-30
This file was deleted.

bench/bench_realtime_ops/common.go

-41
This file was deleted.

example_hdr_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package hdrhistogram_test
2+
3+
import (
4+
"fmt"
5+
"github.com/filipecosta90/hdrhistogram"
6+
)
7+
8+
// This latency Histogram could be used to track and analyze the counts of
9+
// observed integer values between 0 us and 30000000 us ( 30 secs )
10+
// while maintaining a value precision of 4 significant digits across that range,
11+
// translating to a value resolution of :
12+
// - 1 microsecond up to 10 milliseconds,
13+
// - 100 microsecond (or better) from 10 milliseconds up to 10 seconds,
14+
// - 300 microsecond (or better) from 10 seconds up to 30 seconds,
15+
func ExampleNew() {
16+
lH := hdrhistogram.New(1, 30000000, 4)
17+
input := []int64{
18+
459876, 669187, 711612, 816326, 931423, 1033197, 1131895, 2477317,
19+
3964974, 12718782,
20+
}
21+
22+
for _, sample := range input {
23+
lH.RecordValue(sample)
24+
}
25+
26+
fmt.Printf("Percentile 50: %d\n", lH.ValueAtQuantile(50.0))
27+
28+
// Output:
29+
// Percentile 50: 931423
30+
}

go.mod

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/filipecosta90/hdrhistogram
2+
3+
go 1.14
4+
5+
require (
6+
code.cloudfoundry.org/bytefmt v0.0.0-20200131002437-cf55d5288a48
7+
github.com/golangci/golangci-lint v1.30.0 // indirect
8+
github.com/stretchr/testify v1.6.1
9+
)

0 commit comments

Comments
 (0)