diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/locale/performance | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/locale/performance')
-rw-r--r-- | src/boost/libs/locale/performance/perf_collate.cpp | 51 | ||||
-rw-r--r-- | src/boost/libs/locale/performance/perf_convert.cpp | 56 | ||||
-rw-r--r-- | src/boost/libs/locale/performance/perf_format.cpp | 39 |
3 files changed, 146 insertions, 0 deletions
diff --git a/src/boost/libs/locale/performance/perf_collate.cpp b/src/boost/libs/locale/performance/perf_collate.cpp new file mode 100644 index 000000000..c0721d8cd --- /dev/null +++ b/src/boost/libs/locale/performance/perf_collate.cpp @@ -0,0 +1,51 @@ +// +// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#include <iostream> +#include <string> +#include <set> + +#include <boost/locale.hpp> + +using namespace std; +using namespace boost::locale; + +int main(int argc,char **argv) +{ + if(argc!=2) { + std::cerr << "Usage backend locale" << std::endl; + return 1; + } + boost::locale::localization_backend_manager mgr = boost::locale::localization_backend_manager::global(); + mgr.select(argv[1]); + generator gen(mgr); + std::locale::global(gen(argv[2])); + /// Set global locale to requested + + /// Create a set that includes all strings sorted according to ABC order + /// std::locale can be used as object for comparison + std::vector<std::string> all; + typedef std::set<std::string,std::locale> set_type; + set_type all_strings; + + /// Read all strings into the set + while(!cin.eof()) { + std::string tmp; + getline(cin,tmp); + all.push_back(tmp); + } + for(int i=0;i<10000;i++) { + std::vector<std::string> tmp = all; + std::sort(tmp.begin(),tmp.end(),std::locale()); + if(i==0) { + for(unsigned j=0;j<tmp.size();j++) + std::cout << tmp[j] << std::endl; + } + } + +} +// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/src/boost/libs/locale/performance/perf_convert.cpp b/src/boost/libs/locale/performance/perf_convert.cpp new file mode 100644 index 000000000..6d69be65f --- /dev/null +++ b/src/boost/libs/locale/performance/perf_convert.cpp @@ -0,0 +1,56 @@ +// +// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#include <iostream> +#include <string> +#include <set> + +#include <boost/locale.hpp> + +using namespace std; +using namespace boost::locale; + +int main(int argc,char **argv) +{ + if(argc!=2) { + std::cerr << "Usage backend locale" << std::endl; + return 1; + } + /// Set global locale to requested + + /// Create a set that includes all strings sorted according to ABC order + /// std::locale can be used as object for comparison + std::vector<std::string> all; + typedef std::set<std::string,std::locale> set_type; + set_type all_strings; + + /// Read all strings into the set + while(!cin.eof()) { + std::string tmp; + getline(cin,tmp); + all.push_back(tmp); + } + + { + boost::locale::localization_backend_manager mgr = boost::locale::localization_backend_manager::global(); + mgr.select(argv[1]); + generator gen(mgr); + std::locale::global(gen(argv[2])); + for(int i=0;i<10000;i++) { + for(unsigned j=0;j<all.size();j++) { + boost::locale::to_upper(all[j]); + boost::locale::to_lower(all[j]); + if(i==0) { + std::cout << boost::locale::to_upper(all[j]) << std::endl; + std::cout << boost::locale::to_lower(all[j]) << std::endl; + } + } + } + } + +} +// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/src/boost/libs/locale/performance/perf_format.cpp b/src/boost/libs/locale/performance/perf_format.cpp new file mode 100644 index 000000000..417e1ba3e --- /dev/null +++ b/src/boost/libs/locale/performance/perf_format.cpp @@ -0,0 +1,39 @@ +// +// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#include <iostream> +#include <string> +#include <set> +#include <ctime> +#include <boost/locale.hpp> + +using namespace std; +using namespace boost::locale; + +int main(int argc,char **argv) +{ + if(argc!=2) { + std::cerr << "Usage backend locale" << std::endl; + return 1; + } + boost::locale::localization_backend_manager mgr = boost::locale::localization_backend_manager::global(); + mgr.select(argv[1]); + generator gen(mgr); + std::locale::global(gen(argv[2])); + /// Set global locale to requested + + for(int i=0;i<100000;i++) { + std::ostringstream ss; + for(int j=0;j<5;j++) { + ss << boost::locale::as::datetime << std::time(0) <<" "<< boost::locale::as::number << 13456.345 <<"\n"; + } + if(i==0) + std::cout << ss.str() << std::endl; + } + +} +// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 |