Skip to content

Commit 4b0ffda

Browse files
committed
Added simple benchmark and refactoring
1 parent fedc447 commit 4b0ffda

18 files changed

+336
-338
lines changed

.clang-format

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
Language: Cpp
2+
Language: Cpp
33
# BasedOnStyle: LLVM
44
AccessModifierOffset: -4
55
AlignAfterOpenBracket: DontAlign
66
AlignConsecutiveAssignments: None
77
AlignConsecutiveDeclarations: None
88
AlignEscapedNewlines: Right
9-
AlignOperands: true
9+
AlignOperands: true
1010
AlignTrailingComments: true
1111
AllowAllParametersOfDeclarationOnNextLine: true
1212
AllowShortBlocksOnASingleLine: Always
@@ -20,18 +20,18 @@ AlwaysBreakBeforeMultilineStrings: false
2020
AlwaysBreakTemplateDeclarations: Yes
2121
BinPackArguments: true
2222
BinPackParameters: true
23-
BraceWrapping:
24-
AfterClass: true
23+
BraceWrapping:
24+
AfterClass: true
2525
AfterControlStatement: Always
26-
AfterEnum: true
27-
AfterFunction: true
28-
AfterNamespace: false
26+
AfterEnum: true
27+
AfterFunction: true
28+
AfterNamespace: false
2929
AfterObjCDeclaration: true
30-
AfterStruct: true
31-
AfterUnion: true
32-
BeforeCatch: true
33-
BeforeElse: true
34-
IndentBraces: false
30+
AfterStruct: true
31+
AfterUnion: true
32+
BeforeCatch: true
33+
BeforeElse: true
34+
IndentBraces: false
3535
SplitEmptyFunction: false
3636
SplitEmptyRecord: false
3737
SplitEmptyNamespace: false
@@ -43,37 +43,37 @@ BreakConstructorInitializersBeforeComma: true
4343
BreakConstructorInitializers: BeforeColon
4444
BreakAfterJavaFieldAnnotations: false
4545
BreakStringLiterals: true
46-
ColumnLimit: 140
47-
CommentPragmas: '^ IWYU pragma:'
48-
CompactNamespaces: false
46+
ColumnLimit: 140
47+
CommentPragmas: '^ IWYU pragma:'
48+
CompactNamespaces: false
4949
ConstructorInitializerAllOnOneLineOrOnePerLine: false
5050
ConstructorInitializerIndentWidth: 4
5151
ContinuationIndentWidth: 4
5252
Cpp11BracedListStyle: true
5353
DerivePointerAlignment: false
54-
DisableFormat: false
54+
DisableFormat: false
5555
ExperimentalAutoDetectBinPacking: false
5656
FixNamespaceComments: true
57-
ForEachMacros:
57+
ForEachMacros:
5858
- foreach
5959
- Q_FOREACH
6060
- BOOST_FOREACH
61-
IncludeCategories:
62-
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
63-
Priority: 2
64-
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
65-
Priority: 3
66-
- Regex: '.*'
67-
Priority: 1
61+
IncludeCategories:
62+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
63+
Priority: 2
64+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
65+
Priority: 3
66+
- Regex: '.*'
67+
Priority: 1
6868
IncludeIsMainRegex: '(Test)?$'
6969
IndentCaseLabels: false
70-
IndentWidth: 4
70+
IndentWidth: 4
7171
IndentWrappedFunctionNames: false
7272
JavaScriptQuotes: Leave
7373
JavaScriptWrapImports: true
7474
KeepEmptyLinesAtTheStartOfBlocks: true
7575
MacroBlockBegin: ''
76-
MacroBlockEnd: ''
76+
MacroBlockEnd: ''
7777
MaxEmptyLinesToKeep: 1
7878
NamespaceIndentation: None
7979
ObjCBlockIndentWidth: 2
@@ -87,7 +87,7 @@ PenaltyBreakString: 1000
8787
PenaltyExcessCharacter: 1000000
8888
PenaltyReturnTypeOnItsOwnLine: 60
8989
PointerAlignment: Right
90-
ReflowComments: true
90+
ReflowComments: true
9191
SortIncludes: Never
9292
SortUsingDeclarations: true
9393
SpaceAfterCStyleCast: false
@@ -96,14 +96,14 @@ SpaceBeforeAssignmentOperators: true
9696
SpaceBeforeParens: ControlStatements
9797
SpaceInEmptyParentheses: false
9898
SpacesBeforeTrailingComments: 1
99-
SpacesInAngles: false
99+
SpacesInAngles: false
100100
SpacesInContainerLiterals: true
101101
SpacesInCStyleCastParentheses: false
102102
SpacesInParentheses: false
103103
SpacesInSquareBrackets: false
104-
Standard: c++17
105-
TabWidth: 8
106-
UseTab: Never
104+
Standard: c++17
105+
TabWidth: 8
106+
UseTab: Never
107107
IndentPPDirectives: AfterHash
108108
...
109109

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
name: auto-clang-format
2-
on: [pull_request, push]
2+
on: [ pull_request, push ]
33

44
jobs:
55
build:
66
runs-on: ubuntu-latest
77

88
steps:
9-
- uses: actions/checkout@v2
10-
- uses: DoozyX/[email protected]
11-
with:
12-
source: '.'
13-
exclude: './third_party ./external'
14-
extensions: 'h,cpp,hpp'
15-
clangFormatVersion: 13
16-
inplace: True
17-
- uses: EndBug/add-and-commit@v4
18-
with:
19-
author_name: Clang Robot
20-
author_email: [email protected]
21-
message: ':art: Committing clang-format changes'
22-
env:
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9+
- uses: actions/checkout@v2
10+
- uses: DoozyX/[email protected]
11+
with:
12+
source: '.'
13+
exclude: './third_party ./external'
14+
extensions: 'h,cpp,hpp'
15+
clangFormatVersion: 13
16+
inplace: True
17+
- uses: EndBug/add-and-commit@v4
18+
with:
19+
author_name: Clang Robot
20+
author_email: [email protected]
21+
message: ':art: Committing clang-format changes'
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/linux.yml

+32-32
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Ubuntu
22

33
on:
44
push:
5-
branches: [dev, main]
5+
branches: [ dev, main ]
66
pull_request:
7-
branches: [dev, main]
8-
7+
branches: [ dev, main ]
8+
99
env:
1010
BUILD_TYPE: Debug
1111

@@ -14,33 +14,33 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v3
18-
19-
- name: Install Dependencies
20-
run: |
21-
sudo apt-get install libboost-all-dev
22-
sudo apt-get install lcov
23-
- name: Configure CMake
24-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_COVERAGE=ON
25-
26-
- name: Build
27-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
28-
29-
- name: Test
30-
working-directory: ${{github.workspace}}/build
31-
run: ctest -C ${{env.BUILD_TYPE}}
32-
33-
- name: Generate coverage reports
34-
working-directory: ${{github.workspace}}
35-
run: |
36-
lcov --directory . --capture --output-file coverage.info
37-
lcov --remove coverage.info '*/test/*' '*/include/utils/*' '*/src/utils/*' --output-file coverage.info
38-
39-
- name: Upload reports to codecov
40-
env:
41-
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
42-
run: |
43-
curl -Os https://uploader.codecov.io/latest/linux/codecov
44-
chmod +x codecov
45-
./codecov -t ${CODECOV_TOKEN}
17+
- uses: actions/checkout@v3
18+
19+
- name: Install Dependencies
20+
run: |
21+
sudo apt-get install libboost-all-dev
22+
sudo apt-get install lcov
23+
- name: Configure CMake
24+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_COVERAGE=ON
25+
26+
- name: Build
27+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
28+
29+
- name: Test
30+
working-directory: ${{github.workspace}}/build
31+
run: ctest -C ${{env.BUILD_TYPE}}
32+
33+
- name: Generate coverage reports
34+
working-directory: ${{github.workspace}}
35+
run: |
36+
lcov --directory . --capture --output-file coverage.info
37+
lcov --remove coverage.info '*/test/*' '*/include/utils/*' '*/src/utils/*' --output-file coverage.info
38+
39+
- name: Upload reports to codecov
40+
env:
41+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
42+
run: |
43+
curl -Os https://uploader.codecov.io/latest/linux/codecov
44+
chmod +x codecov
45+
./codecov -t ${CODECOV_TOKEN}
4646

.github/workflows/macos.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: MacOS
22

33
on:
44
push:
5-
branches: [dev, main]
5+
branches: [ dev, main ]
66
pull_request:
7-
branches: [dev, main]
8-
7+
branches: [ dev, main ]
8+
99
env:
1010
BUILD_TYPE: Debug
1111

@@ -14,18 +14,18 @@ jobs:
1414
runs-on: macos-latest
1515

1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v3
18+
19+
- name: Install Dependencies
20+
run: |
21+
brew install boost
22+
- name: Configure CMake
23+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
1824

19-
- name: Install Dependencies
20-
run: |
21-
brew install boost
22-
- name: Configure CMake
23-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
25+
- name: Build
26+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
2427

25-
- name: Build
26-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
27-
28-
- name: Test
29-
working-directory: ${{github.workspace}}/build
30-
run: ctest -C ${{env.BUILD_TYPE}}
28+
- name: Test
29+
working-directory: ${{github.workspace}}/build
30+
run: ctest -C ${{env.BUILD_TYPE}}
3131

CMakeLists.txt

+15-15
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ FetchContent_MakeAvailable(spdlog)
6363
# ------------------------------------------------------------------------------
6464
# Clang Tidy
6565
# ------------------------------------------------------------------------------
66-
if(ENABLE_CLANG_TIDY)
66+
if (ENABLE_CLANG_TIDY)
6767

6868
find_program(CLANG_TIDY_BIN clang-tidy-4.0)
6969
find_program(RUN_CLANG_TIDY_BIN run-clang-tidy-4.0.py)
7070

71-
if(CLANG_TIDY_BIN STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
71+
if (CLANG_TIDY_BIN STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
7272
message(FATAL_ERROR "unable to locate clang-tidy-4.0")
73-
endif()
73+
endif ()
7474

75-
if(RUN_CLANG_TIDY_BIN STREQUAL "RUN_CLANG_TIDY_BIN-NOTFOUND")
75+
if (RUN_CLANG_TIDY_BIN STREQUAL "RUN_CLANG_TIDY_BIN-NOTFOUND")
7676
message(FATAL_ERROR "unable to locate run-clang-tidy-4.0.py")
77-
endif()
77+
endif ()
7878

7979
list(APPEND RUN_CLANG_TIDY_BIN_ARGS
8080
-clang-tidy-binary ${CLANG_TIDY_BIN}
@@ -86,42 +86,42 @@ if(ENABLE_CLANG_TIDY)
8686
tidy
8787
COMMAND ${RUN_CLANG_TIDY_BIN} ${RUN_CLANG_TIDY_BIN_ARGS}
8888
COMMENT "running clang tidy"
89-
)
89+
)
9090

91-
endif()
91+
endif ()
9292

9393
# ------------------------------------------------------------------------------
9494
# Coverage
9595
# ------------------------------------------------------------------------------
96-
if(ENABLE_COVERAGE)
96+
if (ENABLE_COVERAGE)
9797
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ")
9898
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
9999
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs")
100100
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage")
101101
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
102-
endif()
102+
endif ()
103103

104104
# ------------------------------------------------------------------------------
105105
# Google Sanitizers
106106
# ------------------------------------------------------------------------------
107-
if(ENABLE_ASAN)
107+
if (ENABLE_ASAN)
108108
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
109109
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
110110
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
111111
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
112112
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
113113
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
114-
endif()
114+
endif ()
115115

116-
if(ENABLE_USAN)
116+
if (ENABLE_USAN)
117117
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
118118
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
119-
endif()
119+
endif ()
120120

121-
if(ENABLE_TSAN)
121+
if (ENABLE_TSAN)
122122
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
123123
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
124-
endif()
124+
endif ()
125125

126126
# ------------------------------------------------------------------------------
127127
# Valgrind

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
[![codecov](https://codecov.io/gh/jmsadair/RapidTrader/branch/dev/graph/badge.svg?token=4QQI0QDVYM)](https://codecov.io/gh/jmsadair/RapidTrader)
44

55
# RapidTrader
6+
67
TODO.

benchmark/bench_market.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ static void BM_Market(benchmark::State &state)
3838
for (auto _ : state)
3939
{
4040
state.PauseTiming();
41-
DebugEventHandler handler;
42-
RapidTrader::Matching::ConcurrentMarket market{handler.getSender(), 1};
41+
DebugEventHandler event_handler;
42+
RapidTrader::Matching::ConcurrentMarket market{event_handler.getSender()};
4343
for (int i = 1; i <= num_symbols; ++i)
44-
{
4544
market.addSymbol(i, "MARKET BENCH");
46-
}
4745
state.ResumeTiming();
4846
for (const auto &order : orders)
4947
market.addOrder(order);

0 commit comments

Comments
 (0)