-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Implemented an AlignedAllocator class for increased performance. -Added a string of uint8_ts that is aligned to 32-bytes for working with the to-be-parsed json data, for increased performance as a result of using aligned AVX-Loading functions. -Updated the CMakeLists.txt file. -Updating to fix various compiler warnings. -Switched from using indices into the string to pointers into the string, for iterating the Json data. -Removing instances of C++ aliasing. -Updated the Pair class to support structured binding calls.
- Loading branch information
1 parent
6635ae8
commit c0ceec8
Showing
32 changed files
with
2,181 additions
and
1,329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Build-and-Test-CLANG | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
Build: | ||
runs-on: macos-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
clang: [17] | ||
build_type: [Debug, Release] | ||
std: [20] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Clang17 | ||
run: | | ||
brew install llvm | ||
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile | ||
- name: Configure CMake | ||
working-directory: Tests | ||
run: | | ||
cmake -S . -B ./Build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang-16 -DGITHUB_BRANCH_TYPE=${{github.ref}} | ||
- name: Build the Test | ||
working-directory: Tests/Build | ||
run: | | ||
cmake --build . --config=${{matrix.build_type}} | ||
- name: Run the Test | ||
working-directory: Tests/Build | ||
run: | | ||
./Json-Performance | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,26 +15,17 @@ jobs: | |
matrix: | ||
msvc: [2022] | ||
build_type: [Debug, Release] | ||
std: [23] | ||
std: [20] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ilammy/[email protected] | ||
|
||
- name: Append the directory of 'vcvarsall.bat' to PATH environment variable | ||
uses: myci-actions/export-env-var-powershell@1 | ||
with: | ||
name: PATH | ||
value: $env:PATH;C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build | ||
|
||
- name: Update Vcpkg and install other dependencies. | ||
run: | | ||
cd C:/vcpkg | ||
./bootstrap-vcpkg.bat | ||
git stash | ||
git pull | ||
vcpkg update | ||
- name: Configure CMake | ||
working-directory: Tests | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2023 RealTimeChris | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
software and associated documentation files (the "Software"), to deal in the Software | ||
without restriction, including without limitation the rights to use, copy, modify, merge, | ||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit | ||
persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or | ||
substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. | ||
*/ | ||
/// https://github.com/RealTimeChris/Jsonifier | ||
/// Feb 3, 2023 | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <utility> | ||
#include <memory> | ||
|
||
#if defined(_MSC_VER) | ||
#define ALIGNED_ALLOC(size, alignment) _aligned_malloc(size, alignment) | ||
#define ALIGNED_FREE(ptr) _aligned_free(ptr) | ||
#else | ||
#define ALIGNED_ALLOC(size, alignment) aligned_alloc(alignment, size) | ||
#define ALIGNED_FREE(ptr) free(ptr) | ||
#endif | ||
|
||
namespace JsonifierInternal { | ||
|
||
template<typename ValueType, uint64_t Alignment = alignof(ValueType)> class AlignedAllocator { | ||
public: | ||
using value_type = ValueType; | ||
using pointer = value_type*; | ||
using size_type = uint64_t; | ||
|
||
inline pointer allocate(size_type n) { | ||
if (n == 0) { | ||
return nullptr; | ||
} | ||
|
||
return static_cast<pointer>(ALIGNED_ALLOC(n * sizeof(ValueType), Alignment < 32 ? 32 : Alignment)); | ||
} | ||
|
||
inline void deallocate(pointer p, size_type) { | ||
if (p) { | ||
ALIGNED_FREE(p); | ||
} | ||
} | ||
|
||
template<typename... Args> inline void construct(pointer p, Args&&... args) { | ||
new (p) value_type(std::forward<Args>(args)...); | ||
} | ||
|
||
inline void destroy(pointer p) { | ||
p->~value_type(); | ||
} | ||
}; | ||
|
||
template<typename ValueType> class AllocWrapper : public AlignedAllocator<ValueType> { | ||
public: | ||
using value_type = ValueType; | ||
using pointer = value_type*; | ||
using size_type = uint64_t; | ||
using allocator = AlignedAllocator<value_type>; | ||
using allocator_traits = std::allocator_traits<allocator>; | ||
|
||
inline pointer allocate(size_type count) noexcept { | ||
return allocator_traits::allocate(*this, count); | ||
} | ||
|
||
inline void deallocate(pointer ptr, size_type count) noexcept { | ||
allocator_traits::deallocate(*this, ptr, count); | ||
} | ||
|
||
template<typename... Args> inline void construct(pointer ptr, Args&&... args) noexcept { | ||
allocator_traits::construct(*this, ptr, std::forward<Args>(args)...); | ||
} | ||
|
||
inline void destroy(pointer ptr) noexcept { | ||
allocator_traits::destroy(*this, ptr); | ||
} | ||
}; | ||
|
||
} |
Oops, something went wrong.