From 17be021719c664a230f6d00103bd2918010585c1 Mon Sep 17 00:00:00 2001 From: Phil Mesnier Date: Wed, 6 Apr 2011 13:23:21 +0000 Subject: Wed Apr 6 12:58:38 UTC 2011 Phil Mesnier * performance-tests/Sequence_Latency/Sequence_Operations_Time/README.txt: * performance-tests/Sequence_Latency/Sequence_Operations_Time/Sequence_Ops_Time.mpc: * performance-tests/Sequence_Latency/Sequence_Operations_Time/sequence.idl: * performance-tests/Sequence_Latency/Sequence_Operations_Time/test.cpp: A new test designed to highlight the amount of time spent by dynamically growing sequences of varying element complexity. --- .../Sequence_Operations_Time/README.txt | 20 ++ .../Sequence_Operations_Time/Sequence_Ops_Time.mpc | 25 +++ .../Sequence_Operations_Time/sequence.idl | 34 ++++ .../Sequence_Operations_Time/test.cpp | 223 +++++++++++++++++++++ 4 files changed, 302 insertions(+) create mode 100644 TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/README.txt create mode 100644 TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/Sequence_Ops_Time.mpc create mode 100644 TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/sequence.idl create mode 100644 TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/test.cpp (limited to 'TAO/performance-tests') diff --git a/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/README.txt b/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/README.txt new file mode 100644 index 00000000000..6ccd9d496ab --- /dev/null +++ b/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/README.txt @@ -0,0 +1,20 @@ +// $Id$ + +This test is used to validate the peformance of sequence copying. + +The motivation of this test is that a comparison between DOC & OCI's +release of TAO versus a different ORB showed TAO had a performance +deficit. The performance was improved by using shallow copys for some +sequences, and this test can be used to measure the performance +improvements. + +Output is written to stderr, and can be either easy to read text, or +CSV format for import into a spreadsheet. + +To run the test, use the command line: + +./test + +for CSV: + +./test -csv diff --git a/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/Sequence_Ops_Time.mpc b/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/Sequence_Ops_Time.mpc new file mode 100644 index 00000000000..38c4e767850 --- /dev/null +++ b/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/Sequence_Ops_Time.mpc @@ -0,0 +1,25 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + IDL_Files { + sequence.idl + } + custom_only = 1 +} + + +project(*Test): taoexe { + after += *idl + exename = test + + Source_Files { + test.cpp + } + Source_Files { + sequenceC.cpp + } + IDL_Files { + } +} + diff --git a/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/sequence.idl b/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/sequence.idl new file mode 100644 index 00000000000..671fd4f3cf6 --- /dev/null +++ b/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/sequence.idl @@ -0,0 +1,34 @@ +// $Id$ + +#include "tao/StringSeq.pidl" + +struct Str_Sequences +{ + CORBA::StringSeq first_str; + CORBA::StringSeq second_str; +}; + +typedef sequence StrSeqSeq; + +struct Sequence_Str_Sequences +{ + StrSeqSeq seq_str_seq; + +}; + +typedef sequence Redundant_Sequences; + +struct Biglist_Struct +{ + Str_Sequences strs; + Redundant_Sequences red_seqs; +}; + +typedef sequence BigListSeq; + +struct Seq_Structs +{ + BigListSeq seq; +}; + + diff --git a/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/test.cpp b/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/test.cpp new file mode 100644 index 00000000000..0a0d128e0fd --- /dev/null +++ b/TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/test.cpp @@ -0,0 +1,223 @@ +// Test of raw copy performance when using different sequence allocations +// $Id$ + +#include "sequenceC.h" +#include "ace/Time_Value.h" +#include "ace/High_Res_Timer.h" +#include "ace/OS_NS_strings.h" +#include "ace/Log_Msg.h" + + +const char * short_str = "abcdefghijklmnopqrstuvwxyz"; +const char * long_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"; + +bool use_csv = false; + +void stringseq_time_test (CORBA::ULong num_loops, bool use_long_str) +{ + ACE_High_Res_Timer timer; + ACE_hrtime_t time; + + CORBA::ULong str_len; + + Str_Sequences seqs; + seqs.first_str.length(0); + seqs.second_str.length(0); + + // start timing + timer.start(); + + for (CORBA::ULong idx = 0; idx < num_loops; ++idx) + { + str_len = seqs.first_str.length(); + seqs.first_str.length(str_len + 1); + seqs.first_str[str_len] = use_long_str ? long_str : short_str; + } + // end timing + timer.stop(); + timer.elapsed_time(time); + + if (use_csv) + { + ACE_DEBUG((LM_INFO, + ACE_TEXT("1, 0, 0, %u, %s, %Q\n"), + num_loops, + use_long_str ? ACE_TEXT("long"): ACE_TEXT("short"), + time )); + } + else + { + ACE_DEBUG((LM_INFO, + ACE_TEXT("String sequence (%u, %s) = %Q ns\n"), + num_loops, + use_long_str ? ACE_TEXT("long"): ACE_TEXT("short"), + time )); + } +} + + +void seqstrseq_time_test (CORBA::ULong num_seq_loops, + CORBA::ULong num_string_loops, + bool use_long_str) +{ + ACE_High_Res_Timer timer; + ACE_hrtime_t time; + + CORBA::ULong sss_len; + CORBA::ULong str_len; + + Sequence_Str_Sequences seqs; + seqs.seq_str_seq.length(0); + + // start timing + timer.start(); + + for (CORBA::ULong seq_idx = 0; seq_idx < num_seq_loops; ++seq_idx) + { + sss_len = seqs.seq_str_seq.length(); + seqs.seq_str_seq.length(sss_len + 1); + Str_Sequences & strs = seqs.seq_str_seq[sss_len]; + //strs.first_str.length(0); + for (CORBA::ULong str_idx = 0; str_idx < num_string_loops; ++str_idx) + { + str_len = strs.second_str.length(); + strs.second_str.length(str_len + 1); + strs.second_str[str_len] = use_long_str ? long_str : short_str; + } + } + // end timing + timer.stop(); + timer.elapsed_time(time); + + if (use_csv) + { + ACE_DEBUG((LM_INFO, + ACE_TEXT("2, 0, %u, %u, %s, %Q\n"), + num_string_loops, + num_seq_loops, + use_long_str ? ACE_TEXT("long"): ACE_TEXT("short"), + time )); + } + else + { + ACE_DEBUG((LM_INFO, + ACE_TEXT("Sequence of string seq (%u, %u, %s) = %Q ns\n"), + num_string_loops, + num_seq_loops, + use_long_str ? ACE_TEXT("long"): ACE_TEXT("short"), + time )); + } +} + + +void big_time_test (CORBA::ULong num_list_loops, + CORBA::ULong num_seq_loops, + CORBA::ULong num_string_loops, + bool use_long_str) +{ + ACE_High_Res_Timer timer; + ACE_hrtime_t time; + + Seq_Structs big_list; + big_list.seq.length(0); + + CORBA::ULong big_len; + CORBA::ULong red_len; + CORBA::ULong sss_len; + CORBA::ULong str_len; + + // start timing + timer.start(); + + for (CORBA::ULong list_idx = 0; list_idx < num_list_loops; ++list_idx) + { + big_len = big_list.seq.length(); + big_list.seq.length(big_len + 1); + Biglist_Struct & list = big_list.seq[big_len]; + + for (CORBA::ULong seq_idx = 0; seq_idx < num_seq_loops; ++seq_idx) + { + red_len = list.red_seqs.length(); + list.red_seqs.length(red_len + 1); + + Sequence_Str_Sequences & sss = list.red_seqs[red_len]; + + sss_len = sss.seq_str_seq.length(); + sss.seq_str_seq.length(sss_len + 1); + + Str_Sequences & strs = sss.seq_str_seq[sss_len]; + for (CORBA::ULong str_idx = 0; str_idx < num_string_loops; ++str_idx) + { + str_len = strs.second_str.length(); + strs.second_str.length(str_len + 1); + strs.second_str[str_len] = use_long_str ? long_str : short_str; + + str_len = list.strs.first_str.length(); + list.strs.first_str.length(str_len + 1); + list.strs.first_str[str_len] = use_long_str ? long_str : short_str; + + } // end of str loop + } // end of seq loop + + } // end of list loop + // end timing + timer.stop(); + timer.elapsed_time(time); + + if (use_csv) + { + ACE_DEBUG((LM_INFO, + ACE_TEXT("3, %u, %u, %u, %s, %Q\n"), + num_list_loops, + num_string_loops, + num_seq_loops, + use_long_str ? ACE_TEXT("long"): ACE_TEXT("short"), + time )); + } + else + { + ACE_DEBUG((LM_INFO, + ACE_TEXT("Big list test(%u, %u, %u, %s) = %Q ns\n"), + num_list_loops, + num_string_loops, + num_seq_loops, + use_long_str ? ACE_TEXT("long"): ACE_TEXT("short"), + time )); + } +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + + if (argc > 1 && ACE_OS::strcasecmp (argv[1],ACE_TEXT("-csv")) == 0) + use_csv = true; + + stringseq_time_test(100, false); + stringseq_time_test(1000, false); + + stringseq_time_test(100, true); + stringseq_time_test(1000, true); + + + seqstrseq_time_test(100, 1, false); + seqstrseq_time_test(100, 10, false); + seqstrseq_time_test(1000, 10, false); + + seqstrseq_time_test(100, 1, true); + seqstrseq_time_test(100, 10, true); + seqstrseq_time_test(1000, 10, true); + + + big_time_test(10, 1, 10, false); + big_time_test(10, 1, 10, false); + big_time_test(10, 10, 10, false); + big_time_test(100, 1, 10, false); + + big_time_test(10, 1, 10, true); + big_time_test(10, 1, 10, true); + big_time_test(10, 10, 10, true); + big_time_test(100, 1, 10, true); + + return 0; +} -- cgit v1.2.1