summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorarvindk <arvindk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-04-09 22:21:04 +0000
committerarvindk <arvindk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-04-09 22:21:04 +0000
commit79ab053483a62eeec6391d3f48097f85e07e1045 (patch)
tree832ba1e453bd3baa6bac37d54cd37e11d4a65fd9 /tests
parenta2b57388c766590bb9c8561a5f05f62db6ba4df8 (diff)
downloadATCD-79ab053483a62eeec6391d3f48097f85e07e1045.tar.gz
ChangelogTag: Sat Apr 9 17:00:37 2005 Arvind S. Krishna <arvindk@dre.vanderbilt.edu>
Diffstat (limited to 'tests')
-rw-r--r--tests/Memcpy_Test.cpp89
-rw-r--r--tests/run_test.lst1
-rw-r--r--tests/tests.mpc7
3 files changed, 97 insertions, 0 deletions
diff --git a/tests/Memcpy_Test.cpp b/tests/Memcpy_Test.cpp
new file mode 100644
index 00000000000..8dccd5fe40e
--- /dev/null
+++ b/tests/Memcpy_Test.cpp
@@ -0,0 +1,89 @@
+//$Id$
+
+#include "ace/Time_Value.h"
+#include "ace/OS_NS_time.h"
+#include "test_config.h"
+
+void*
+smemcpy( void* dest, const void* src, const size_t n)
+{
+ unsigned char* to = static_cast<unsigned char*>( dest) ;
+ const unsigned char* from = static_cast<const unsigned char*>( src) ;
+ // Unroll the loop...
+ switch( n) {
+ case 16: to[ 15] = from[ 15] ;
+ case 15: to[ 14] = from[ 14] ;
+ case 14: to[ 13] = from[ 13] ;
+ case 13: to[ 12] = from[ 12] ;
+ case 12: to[ 11] = from[ 11] ;
+ case 11: to[ 10] = from[ 10] ;
+ case 10: to[ 9] = from[ 9] ;
+ case 9: to[ 8] = from[ 8] ;
+ case 8: to[ 7] = from[ 7] ;
+ case 7: to[ 6] = from[ 6] ;
+ case 6: to[ 5] = from[ 5] ;
+ case 5: to[ 4] = from[ 4] ;
+ case 4: to[ 3] = from[ 3] ;
+ case 3: to[ 2] = from[ 2] ;
+ case 2: to[ 1] = from[ 1] ;
+ case 1: to[ 0] = from[ 0] ;
+ case 0: return dest ;
+ default: return memcpy( dest, src, n) ;
+ }
+}
+
+void
+testit( int type)
+{
+ char buffer[16] ;
+ size_t size = 16 ;
+
+ switch( type) {
+ case 0: smemcpy( (void*)buffer, (void*)" THIS IS A TEST", size) ; break ;
+ case 1: memcpy( (void*)buffer, (void*)" THIS IS A TEST", size) ; break ;
+ }
+
+}
+
+namespace { enum { ITERATIONS = 1000000 } ; }
+
+int
+run_main (int, ACE_TCHAR *[])
+{
+ ACE_START_TEST (ACE_TEXT ("Memcopy Performance Test"));
+
+ //ACE_Time_Value start, now ;
+ struct timeval start, now;
+
+ for( int i = ITERATIONS ; i > 0 ; --i) {
+ testit( 0) ;
+ }
+
+ start = ACE_OS::gettimeofday () ;
+ for( int i = ITERATIONS ; i > 0 ; --i) {
+ testit( 0) ;
+ }
+
+ now = ACE_OS::gettimeofday() ;
+
+ double fast = 1000000 * (now.tv_sec - start.tv_sec) +
+ now.tv_usec - start.tv_usec ;
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%f uSec per iteration for fast version.\n"),
+ fast / ITERATIONS
+ )) ;
+
+ start = ACE_OS::gettimeofday () ;
+ for( int i = ITERATIONS ; i > 0 ; --i) {
+ testit( 1) ;
+ }
+ now = ACE_OS::gettimeofday() ;
+
+ double slow = 1000000 * (now.tv_sec-start.tv_sec) + now.tv_usec - start.tv_usec ;
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%f uSec per iteration for fast version.\n"),
+ slow / ITERATIONS
+ )) ;
+
+ return 0 ;
+}
diff --git a/tests/run_test.lst b/tests/run_test.lst
index c20800093ca..ffeff5a5d38 100644
--- a/tests/run_test.lst
+++ b/tests/run_test.lst
@@ -71,6 +71,7 @@ Map_Manager_Test
Map_Test
Max_Default_Port_Test: !ST
Mem_Map_Test: !chorus !Unicos !VxWorks
+Memcpy_Test
Message_Block_Test: !chorus
Message_Queue_Notifications_Test
Message_Queue_Test: !chorus
diff --git a/tests/tests.mpc b/tests/tests.mpc
index 2242cb04395..7e713ec2c2b 100644
--- a/tests/tests.mpc
+++ b/tests/tests.mpc
@@ -154,6 +154,13 @@ project(Cache Map Manager Test) : acetest {
}
}
+project(Mem Copy Test) : acetest {
+ exename = Memcpy_Test
+ Source_Files {
+ Memcpy_Test.cpp
+ }
+}
+
project(Cached Accept Conn Test) : acetest {
exename = Cached_Accept_Conn_Test
Source_Files {