diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2004-01-14 04:11:57 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2004-01-14 04:11:57 +0000 |
commit | 070ce57b9526cf19d545ed56a9f4a2475a2c9261 (patch) | |
tree | 7f702b5470b7e06c397fe020d20c27389efcb18a | |
parent | 5b8d96f1093274d0cf640c9b71d837328f7526b3 (diff) | |
download | gcc-070ce57b9526cf19d545ed56a9f4a2475a2c9261.zip gcc-070ce57b9526cf19d545ed56a9f4a2475a2c9261.tar.gz gcc-070ce57b9526cf19d545ed56a9f4a2475a2c9261.tar.bz2 |
ifstream_extract_float.cc: Add higher precision tests.
2
2004-01-13 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/performance/ifstream_extract_float.cc: Add higher
precision tests.
* testsuite/performance/ofstream_insert_float.cc: Same.
From-SVN: r75841
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/performance/ifstream_extract_float.cc | 33 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/performance/ofstream_insert_float.cc | 47 |
3 files changed, 61 insertions, 25 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0c0720e..fab586e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2004-01-13 Benjamin Kosnik <bkoz@redhat.com> + + * testsuite/performance/ifstream_extract_float.cc: Add higher + precision tests. + * testsuite/performance/ofstream_insert_float.cc: Same. + 2004-01-13 Paolo Carlini <pcarlini@suse.de> * src/locale-misc-inst.cc (__convert_from_v(long), diff --git a/libstdc++-v3/testsuite/performance/ifstream_extract_float.cc b/libstdc++-v3/testsuite/performance/ifstream_extract_float.cc index 5c6b421..55710c2 100644 --- a/libstdc++-v3/testsuite/performance/ifstream_extract_float.cc +++ b/libstdc++-v3/testsuite/performance/ifstream_extract_float.cc @@ -26,36 +26,51 @@ // the GNU General Public License. #include <fstream> +#include <sstream> #include <testsuite_performance.h> -int main() +void test_extraction(int p = 6) { using namespace std; using namespace __gnu_test; - time_counter time; - resource_counter resource; + const char* filename = "tmp_perf_float.txt"; const int iterations = 10000000; + ostringstream oss; + oss << "precision " << p; + + // Construct data. { - ofstream out("tmp_perf_float.txt"); + ofstream out(filename); + out.precision(p); for (int i = 0; i < iterations; ++i) { float f = i * 3.14159265358979323846; - out << f << "\n"; + out << f << '\n'; } } { - ifstream in("tmp_perf_float.txt"); + time_counter time; + resource_counter resource; + + ifstream in(filename); + in.precision(p); float f; start_counters(time, resource); for (int j, i = 0; i < iterations; ++i) in >> f; stop_counters(time, resource); - report_performance(__FILE__, "", time, resource); + report_performance(__FILE__, oss.str(), time, resource); } - unlink("tmp_perf_int.txt"); - return 0; + unlink(filename); }; + +int main() +{ + test_extraction(6); + test_extraction(12); + return 0; +} diff --git a/libstdc++-v3/testsuite/performance/ofstream_insert_float.cc b/libstdc++-v3/testsuite/performance/ofstream_insert_float.cc index 57e8c0e..45d55af 100644 --- a/libstdc++-v3/testsuite/performance/ofstream_insert_float.cc +++ b/libstdc++-v3/testsuite/performance/ofstream_insert_float.cc @@ -26,28 +26,43 @@ // the GNU General Public License. #include <fstream> +#include <sstream> #include <testsuite_performance.h> -// based on libstdc++/8761 poor fstream performance (converted to float) -int main() +// Based on libstdc++/8761 poor fstream performance (converted to float) +void test_insertion(int p = 6) { using namespace std; using namespace __gnu_test; - time_counter time; - resource_counter resource; + const char* filename = "tmp_perf_float.txt"; const int iterations = 10000000; - ofstream out("tmp_perf_float.txt"); - start_counters(time, resource); - for (int i = 0; i < iterations; ++i) - { - float f = i * 3.14159265358979323846; - out << f << "\n"; - } - stop_counters(time, resource); - report_performance(__FILE__, "", time, resource); - - unlink("tmp_perf_float.txt"); - return 0; + ostringstream oss; + oss << "precision " << p; + + { + time_counter time; + resource_counter resource; + + ofstream out(filename); + out.precision(p); + start_counters(time, resource); + for (int i = 0; i < iterations; ++i) + { + float f = i * 3.14159265358979323846; + out << f << '\n'; + } + stop_counters(time, resource); + report_performance(__FILE__, oss.str(), time, resource); + } + + unlink(filename); }; + +int main() +{ + test_insertion(6); + test_insertion(12); + return 0; +} |