OSDN Git Service

2
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Jan 2004 04:11:57 +0000 (04:11 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Jan 2004 04:11:57 +0000 (04:11 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75841 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/performance/ifstream_extract_float.cc
libstdc++-v3/testsuite/performance/ofstream_insert_float.cc

index 0c0720e..fab586e 100644 (file)
@@ -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),
index 5c6b421..55710c2 100644 (file)
 // 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;
+}
index 57e8c0e..45d55af 100644 (file)
 // 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;
+}