Skip to content

Commit

Permalink
Merge pull request #1 from RedisBloom/origin.fix
Browse files Browse the repository at this point in the history
Fixed remote and added testing documentation.
  • Loading branch information
filipecosta90 authored Nov 15, 2020
2 parents 3fbb66e + 42f8b5a commit 3ccf6d4
Show file tree
Hide file tree
Showing 11 changed files with 445 additions and 333 deletions.
45 changes: 40 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
version: 2.1

jobs:
lint:
docker:
- image: redislabsmodules/llvm-toolset:latest
steps:
- checkout
- run:
name: lint
command: |
make lint
static-analysis-infer:
docker:
- image: redisbench/infer-linux64:1.0.0
steps:
- checkout
- run:
name: Submodule checkout
command: git submodule update --init --recursive
- run:
name: run fbinfer
command: |
CC=clang CXX=clang++ INFER=infer make static-analysis
build:
docker:
- image: "debian:stretch"
Expand Down Expand Up @@ -32,10 +54,23 @@ jobs:
name: Build & Test
command: |
make clean
make unit_tests
cd build
make test ARGS="-V"
make coverage
bash <(curl -s https://codecov.io/bash) -f coverage.info -X gcov -x gcov-7 || echo "Codecov did not collect coverage reports"
cd build && bash <(curl -s https://codecov.io/bash) -f coverage.info -X gcov -x gcov-7 || echo "Codecov did not collect coverage reports"
workflows:
commit:
jobs:
- lint
- build
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs:
- build
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
IndentWidth: 4
ColumnLimit: 100
SortIncludes: false
AlignEscapedNewlinesLeft: false
SpacesBeforeTrailingComments: 1
21 changes: 21 additions & 0 deletions .github/release-drafter-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name-template: 'Version $NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
categories:
- title: 'Features'
labels:
- 'feature'
- 'enhancement'
- title: 'Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: 'Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
exclude-labels:
- 'skip-changelog'
template: |
## Changes
$CHANGES
19 changes: 19 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
with:
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
config-name: release-drafter-config.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ build/*
.vscode
tests/vendor/*

# perf related
perf.data*


# fb infer static analysis
infer-out/*

# Prerequisites
*.d

Expand Down
60 changes: 52 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
# Use CMAKE_LIBRARY_OPTIONS,CMAKE_LIBRARY_SHARED_OPTIONS,CMAKE_LIBRARY_STATIC_OPTIONS or CMAKE_FULL_OPTIONS argument to this Makefile to pass options to cmake.
#----------------------------------------------------------------------------------------------------

CC?=gcc
INFER?=./deps/infer
INFER_DOCKER?=redisbench/infer-linux64:1.0.0
ROOT=$(shell pwd)
SRCDIR := $(ROOT)/src

ifndef CMAKE_LIBRARY_SHARED_OPTIONS
CMAKE_LIBRARY_SHARED_OPTIONS=\
-DBUILD_SHARED=ON \
-DBUILD_STATIC=OFF \
-DENABLE_FRAME_POINTER=ON \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCHMARK=OFF \
-DBUILD_EXAMPLES=OFF
Expand All @@ -18,6 +25,7 @@ ifndef CMAKE_LIBRARY_STATIC_OPTIONS
-DBUILD_SHARED=OFF \
-DBUILD_STATIC=ON \
-DENABLE_FRAME_POINTER=ON \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCHMARK=OFF \
-DBUILD_EXAMPLES=OFF
Expand All @@ -28,6 +36,7 @@ ifndef CMAKE_LIBRARY_OPTIONS
-DBUILD_SHARED=ON \
-DBUILD_STATIC=ON \
-DENABLE_FRAME_POINTER=ON \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCHMARK=OFF \
-DBUILD_EXAMPLES=OFF
Expand All @@ -38,6 +47,7 @@ ifndef CMAKE_FULL_OPTIONS
-DBUILD_SHARED=ON \
-DBUILD_STATIC=ON \
-DENABLE_FRAME_POINTER=ON \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=ON \
-DBUILD_BENCHMARK=ON \
-DBUILD_EXAMPLES=ON
Expand All @@ -59,28 +69,62 @@ default: full

# just build the static library. Do not build tests or benchmarks
library_static:
( cd build ; cmake $(CMAKE_LIBRARY_STATIC_OPTIONS) .. ; $(MAKE) )
( mkdir -p build; cd build ; cmake $(CMAKE_LIBRARY_STATIC_OPTIONS) .. ; $(MAKE) )

# just build the shared library. Do not build tests or benchmarks
library_shared:
( cd build ; cmake $(CMAKE_LIBRARY_SHARED_OPTIONS) .. ; $(MAKE) )
( mkdir -p build; cd build ; cmake $(CMAKE_LIBRARY_SHARED_OPTIONS) .. ; $(MAKE) )

# just build the static and shared libraries. Do not build tests or benchmarks
library_all:
( cd build ; cmake $(CMAKE_LIBRARY_OPTIONS) .. ; $(MAKE) )
( mkdir -p build; cd build ; cmake $(CMAKE_LIBRARY_OPTIONS) .. ; $(MAKE) )

# just build the static and shared libraries and produce measurements
# of accuracy versus compression factor for fixed data size
# TODO:

# just build the static and shared libraries and tests
unit_tests:
( cd build ; cmake $(CMAKE_TEST_OPTIONS) .. ; $(MAKE) )
unit_tests:
( mkdir -p build; cd build ; cmake $(CMAKE_TEST_OPTIONS) .. ; $(MAKE) ; $(MAKE) test )

test:
$(MAKE) unit_tests

coverage:
( mkdir -p build; cd build ; cmake $(CMAKE_TEST_OPTIONS) .. ; $(MAKE) ; $(MAKE) test; make coverage; )

format:
clang-format -style=file -i $(SRCDIR)/*.c
clang-format -style=file -i $(SRCDIR)/*.h

lint:
clang-format -style=file -Werror -n $(SRCDIR)/*.c
clang-format -style=file -Werror -n $(SRCDIR)/*.h

# build all
full:
( cd build ; cmake $(CMAKE_FULL_OPTIONS) .. ; $(MAKE) )
( mkdir -p build; cd build ; cmake $(CMAKE_FULL_OPTIONS) .. ; $(MAKE) VERBOSE=1 )

# static-analysis-docker:
# $(MAKE) clean
# docker run -v $(ROOT)/:/t-digest-c/ --user "$(username):$(usergroup)" $(INFER_DOCKER) bash -c "cd t-digest-c && CC=clang infer run --keep-going --fail-on-issue --biabduction -- make test"

clean: distclean

distclean:
rm -rf build/*

bench: full
$(SHOW) build/tests/histogram_benchmark --benchmark_min_time=10
bench: clean
CFLAGS="-g -fno-omit-frame-pointer " CXXFLAGS="-g -fno-omit-frame-pointer " $(MAKE)
$(SHOW) build/tests/histogram_benchmark --benchmark_min_time=10

perf-stat-bench:
CFLAGS="-g -fno-omit-frame-pointer " CXXFLAGS="-g -fno-omit-frame-pointer " $(MAKE)
$(SHOW) perf stat build/tests/histogram_benchmark --benchmark_min_time=10

perf-record-bench:
CFLAGS="-g -fno-omit-frame-pointer " CXXFLAGS="-g -fno-omit-frame-pointer " $(MAKE)
$(SHOW) perf record -g -o perf.data.td_add build/tests/histogram_benchmark --benchmark_min_time=10

perf-report-bench:
$(SHOW) perf report -g 'graph,0.5,caller' -i perf.data.td_add
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

![License](https://img.shields.io/badge/License-MIT-blue.svg)
[![CircleCI](https://circleci.com/gh/RedisBloom/tdigest.svg?style=svg)](https://circleci.com/gh/RedisBloom/tdigest)
[![codecov](https://codecov.io/gh/filipecosta90/tdigest/branch/master/graph/badge.svg)](https://codecov.io/gh/filipecosta90/tdigest)
[![CircleCI](https://circleci.com/gh/RedisBloom/t-digest-c.svg?style=svg)](https://circleci.com/gh/RedisBloom/t-digest-c)
[![codecov](https://codecov.io/gh/RedisBloom/t-digest-c/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisBloom/t-digest-c)

# T-Digest

Adaptive histogram based on something like streaming k-means crossed with Q-digest.
Expand Down Expand Up @@ -52,11 +53,19 @@ The following functions are implemented:

```
# Build
git clone https://github.com/filipecosta90/tdigest.git
cd tdigest/
git clone https://github.com/RedisBloom/t-digest-c.git
cd t-digest-c/
git submodule update --init --recursive
make
```

## Testing
Assuming you've followed the previous build steps, it should be as easy as:
```
# Run the unit tests
make test
```

## Benchmarking

Assuming you've followed the previous build steps, it should be as easy as:
Expand Down
4 changes: 0 additions & 4 deletions build/.gitignore

This file was deleted.

12 changes: 6 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ FILE(GLOB c_files "*.c")
FILE(GLOB header_files "*.h")

if (BUILD_SHARED)
add_library(tdigest SHARED ${c_files} ${header_files})
add_library(tdigest SHARED ${c_files} ${header_files})
target_link_libraries(tdigest m)
target_include_directories(tdigest SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
install(TARGETS tdigest DESTINATION lib${LIB_SUFFIX})
endif (BUILD_SHARED)
install(TARGETS tdigest DESTINATION lib${LIB_SUFFIX})
endif(BUILD_SHARED)

if (BUILD_STATIC)
add_library(tdigest_static STATIC ${c_files} ${header_files})
if (BUILD_STATIC)
add_library(tdigest_static STATIC ${c_files} ${header_files})
target_link_libraries(tdigest_static m)
target_include_directories(tdigest_static SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
install(TARGETS tdigest_static DESTINATION lib${LIB_SUFFIX})
endif (BUILD_STATIC)
endif(BUILD_STATIC)
Loading

0 comments on commit 3ccf6d4

Please sign in to comment.