summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/testsuite/performance/complex_norm.cc
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-19 04:00:59 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-19 04:00:59 +0000
commitef8b25b2c9d4e42bfb75288235abd0c47c704837 (patch)
tree5fb5e827f14d1e3b023cb8539f22b20c7c5bf70c /libstdc++-v3/testsuite/performance/complex_norm.cc
parent807be5b4953a6307c98b5318fa0f163ac9bb78cf (diff)
downloadppe42-gcc-ef8b25b2c9d4e42bfb75288235abd0c47c704837.tar.gz
ppe42-gcc-ef8b25b2c9d4e42bfb75288235abd0c47c704837.zip
2003-06-18 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/testsuite_performance.h (time_counter): New. (resource_counter): New. (report_performance): New. (start_counters): New. (stop_counters): New. (clear_counters): New. * testsuite/performance/allocator.cc: Instrument. * testsuite/performance/cout_insert_int.cc: Same. * testsuite/performance/complex_norm.cc: Same. * testsuite/performance/filebuf_sputc.cc: New. * testsuite/performance/fstream_seek_write.cc: Same. * testsuite/performance/ifstream_getline.cc: Same. * testsuite/performance/map_create_fill.cc: Same. * testsuite/performance/ofstream_insert_float.cc: Same. * testsuite/performance/ofstream_insert_int.cc: Same. * testsuite/performance/string_append.cc: Convert. * scripts/check_performance: New. * testsuite/Makefile.am (check-performance): New. (CLEANFILES): Add. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68175 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/performance/complex_norm.cc')
-rw-r--r--libstdc++-v3/testsuite/performance/complex_norm.cc34
1 files changed, 29 insertions, 5 deletions
diff --git a/libstdc++-v3/testsuite/performance/complex_norm.cc b/libstdc++-v3/testsuite/performance/complex_norm.cc
index 4a4277634cd..952e727ba56 100644
--- a/libstdc++-v3/testsuite/performance/complex_norm.cc
+++ b/libstdc++-v3/testsuite/performance/complex_norm.cc
@@ -26,34 +26,58 @@
// the GNU General Public License.
#include <complex>
+#include <testsuite_performance.h>
// based on libstdc++/5730, use --fast-math
int main()
{
- typedef std::complex<double> complex_type;
+ using namespace std;
+ using namespace __gnu_cxx_test;
+
+ time_counter time;
+ resource_counter resource;
+ const int iterations = 2000;
+
+ typedef complex<double> complex_type;
complex_type u[2048];
for (int i = 0; i < 2048; ++i)
u[i] = 1.0;
- for (int i = 0; i < 2000; ++i)
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
{
complex_type * p = u;
for (int j = 0; j < 2048; ++j)
{
-#if 1
double u2 = norm(*p);
-#else
+ double t = u2 * 0.1;
+ *p *= complex_type(cos(t), sin(t));
+ ++p;
+ }
+ }
+ stop_counters(time, resource);
+ report_performance(__FILE__, "norm", time, resource);
+ clear_counters(time, resource);
+
+ start_counters(time, resource);
+ for (int i = 0; i < iterations; ++i)
+ {
+ complex_type * p = u;
+ for (int j = 0; j < 2048; ++j)
+ {
// Shouldn't be slower than the above.
double ur = real(*p);
double ui = imag(*p);
double u2 = ur * ur + ui * ui;
-#endif
double t = u2 * 0.1;
*p *= complex_type(cos(t), sin(t));
++p;
}
}
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
return 0;
}
OpenPOWER on IntegriCloud