-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cppfastio/master
dsal
- Loading branch information
Showing
13 changed files
with
793 additions
and
6 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
benchmark/0011.containers/vector/0000.initialization/fast_io.cc
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,9 @@ | ||
#include<fast_io.h> | ||
#include<fast_io_driver/timer.h> | ||
#include<fast_io_dsal/vector.h> | ||
|
||
int main() | ||
{ | ||
fast_io::timer t(u8"fast_io::vector"); | ||
fast_io::vector<std::size_t> vec(100000000); | ||
} |
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,9 @@ | ||
#include<fast_io.h> | ||
#include<fast_io_driver/timer.h> | ||
#include<vector> | ||
|
||
int main() | ||
{ | ||
fast_io::timer t(u8"std::vector"); | ||
std::vector<std::size_t> vec(100000000); | ||
} |
15 changes: 15 additions & 0 deletions
15
benchmark/0011.containers/vector/0001.push_back/fast_io.cc
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,15 @@ | ||
#include<fast_io.h> | ||
#include<fast_io_driver/timer.h> | ||
#include<fast_io_dsal/vector.h> | ||
|
||
int main() | ||
{ | ||
fast_io::timer tm(u8"fast_io::vector::push_back"); | ||
fast_io::vector<std::size_t> vec; | ||
constexpr std::size_t n{100000000}; | ||
vec.reserve(n); | ||
for(std::size_t i{};i!=n;++i) | ||
{ | ||
vec.emplace_back(i); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
benchmark/0011.containers/vector/0001.push_back/fast_io_unchecked.cc
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,15 @@ | ||
#include<fast_io.h> | ||
#include<fast_io_driver/timer.h> | ||
#include<fast_io_dsal/vector.h> | ||
|
||
int main() | ||
{ | ||
fast_io::timer tm(u8"fast_io::vector::push_back_unchecked"); | ||
fast_io::vector<std::size_t> vec; | ||
constexpr std::size_t n{100000000}; | ||
vec.reserve(n); | ||
for(std::size_t i{};i!=n;++i) | ||
{ | ||
vec.push_back_unchecked(i); | ||
} | ||
} |
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,15 @@ | ||
#include<fast_io.h> | ||
#include<fast_io_driver/timer.h> | ||
#include<vector> | ||
|
||
int main() | ||
{ | ||
fast_io::timer tm(u8"std::vector::push_back"); | ||
std::vector<std::size_t> vec; | ||
constexpr std::size_t n{100000000}; | ||
vec.reserve(n); | ||
for(std::size_t i{};i!=n;++i) | ||
{ | ||
vec.push_back(i); | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
benchmark/0011.containers/vector/0002.multi_push_back/vector.cc
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,92 @@ | ||
#include<fast_io.h> | ||
#include<fast_io_driver/timer.h> | ||
#if defined(USE_STD) | ||
#include<vector> | ||
#include<cstdint> | ||
namespace test | ||
{ | ||
template<typename T> | ||
using vector = ::std::vector<T>; | ||
} | ||
#else | ||
#include<fast_io_dsal/vector.h> | ||
|
||
namespace test | ||
{ | ||
template<typename T> | ||
using vector = ::fast_io::vector<T>; | ||
} | ||
#endif | ||
|
||
|
||
/* | ||
Unfortunately fast_io internally sometimes uses vector despite i try to avoid them. Well then better expose the APIs | ||
*/ | ||
|
||
int main() | ||
{ | ||
fast_io::timer t( | ||
#if defined(USE_STD) | ||
u8"std::vectors" | ||
#else | ||
u8"fast_io::vectors" | ||
#endif | ||
); | ||
test::vector<std::int_least32_t> vec1; | ||
test::vector<char32_t> vec2; | ||
test::vector<double> vec3; | ||
test::vector<float> vec4; | ||
test::vector<char> vec5; | ||
test::vector<unsigned char> vec6; | ||
for(std::size_t i{};i!=10000000;++i) | ||
{ | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec3.push_back(43); | ||
vec4.push_back(43); | ||
vec5.push_back(43); | ||
vec6.push_back(43); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec3.push_back(43); | ||
vec4.push_back(43); | ||
vec5.push_back(43); | ||
vec6.push_back(43); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec3.push_back(43); | ||
vec4.push_back(43); | ||
vec5.push_back(43); | ||
vec6.push_back(43); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec3.push_back(43); | ||
vec4.push_back(43); | ||
vec5.push_back(43); | ||
vec6.push_back(43); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec3.push_back(43); | ||
vec4.push_back(43); | ||
vec5.push_back(43); | ||
vec6.push_back(43); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec3.push_back(43); | ||
vec4.push_back(43); | ||
vec5.push_back(43); | ||
vec6.push_back(43); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec3.push_back(43); | ||
vec4.push_back(43); | ||
vec5.push_back(43); | ||
vec6.push_back(43); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec3.push_back(43); | ||
vec4.push_back(43); | ||
vec5.push_back(44); | ||
vec6.push_back(44); | ||
} | ||
} |
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,35 @@ | ||
#if defined(USE_STD) | ||
#include<vector> | ||
#include<cstdint> | ||
namespace test | ||
{ | ||
template<typename T> | ||
using vector = ::std::vector<T>; | ||
} | ||
#else | ||
#include<fast_io_dsal/vector.h> | ||
|
||
namespace test | ||
{ | ||
template<typename T> | ||
using vector = ::fast_io::vector<T>; | ||
} | ||
#endif | ||
|
||
/* | ||
Unfortunately fast_io internally sometimes uses vector despite i try to avoid them. Well then better expose the APIs | ||
*/ | ||
|
||
int main() | ||
{ | ||
test::vector<std::int_least32_t> vec1; | ||
test::vector<char32_t> vec2; | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
vec1.push_back(42); | ||
vec2.push_back(42); | ||
} |
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,30 @@ | ||
#if defined(USE_STD) | ||
#include<vector> | ||
#include<cstdint> | ||
namespace test | ||
{ | ||
template<typename T> | ||
using vector = ::std::vector<T>; | ||
} | ||
#else | ||
#include<fast_io_dsal/vector.h> | ||
|
||
namespace test | ||
{ | ||
template<typename T> | ||
using vector = ::fast_io::vector<T>; | ||
} | ||
#endif | ||
|
||
/* | ||
Unfortunately fast_io internally sometimes uses vector despite i try to avoid them. Well then better expose the APIs | ||
*/ | ||
|
||
int main() | ||
{ | ||
test::vector<test::vector<std::int_least32_t>> vec1; | ||
test::vector<test::vector<char32_t>> vec2; | ||
vec1.emplace_back(); | ||
vec1.emplace_back(); | ||
vec1.emplace_back(); | ||
} |
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,18 @@ | ||
#pragma once | ||
|
||
namespace fast_io::freestanding | ||
{ | ||
|
||
template<typename T> | ||
struct is_trivially_relocatable | ||
{ | ||
inline static constexpr bool value = | ||
#if defined(__clang__) && defined(__has_extension) && __has_cpp_attribute(clang::trivial_abi) | ||
__is_trivially_relocatable(T) || | ||
#endif | ||
::std::is_trivially_copyable_v<T>; | ||
}; | ||
|
||
template<typename T> | ||
inline constexpr bool is_trivially_relocatable_v = is_trivially_relocatable<T>::value; | ||
} |
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
Oops, something went wrong.