Created
November 8, 2016 14:53
-
-
Save ldionne/bf105d0ee029774677ef55c3e2e409c1 to your computer and use it in GitHub Desktop.
Benchmark of hana::string w/ c_str() method
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
# Copyright Louis Dionne 2016 | |
# Distributed under the Boost Software License, Version 1.0. | |
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
set(datasets) | |
add_dataset(datasets hetero make hana string1 hana.string.cpp.erb 4 "(0..50).step(10).to_a + (100..300).step(50).to_a" "which\;1") | |
add_dataset(datasets hetero make hana string2 hana.string.cpp.erb 4 "(0..50).step(10).to_a + (100..300).step(50).to_a" "which\;2") | |
add_chart(hetero make DATASETS ${datasets}) |
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
// Copyright Louis Dionne 2016 | |
// Distributed under the Boost Software License, Version 1.0. | |
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
<% if env[:which] == 1 %> | |
template <char ...s> | |
struct string { | |
private: | |
static constexpr char const storage[sizeof...(s) + 1] = {s..., '\0'}; | |
public: | |
static constexpr char const* c_str() { | |
return &storage[0]; | |
} | |
}; | |
template <char ...s> | |
constexpr char const string<s...>::storage[sizeof...(s) + 1]; | |
<% else %> | |
template <char ...s> | |
constexpr char const storage[sizeof...(s) + 1] = {s..., '\0'}; | |
template <char ...s> | |
struct string { | |
public: | |
static constexpr char const* c_str() { | |
return &storage<s...>[0]; | |
} | |
}; | |
<% end %> | |
template<int> struct x {}; | |
int main() { | |
#if defined(METABENCH) | |
<% env[:k].times do |k| %> | |
<% (0..n).each do |i| %> | |
auto x<%= k %>_<%= i %> = string<<%= ([(k+i) % 128] * 100).join(', ') %>>{}; | |
<% end %> | |
<% end %> | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment