1 // Test of raw copy performance when using different sequence allocations
3 #include "ace/Time_Value.h"
4 #include "ace/High_Res_Timer.h"
5 #include "ace/OS_NS_strings.h"
6 #include "ace/Log_Msg.h"
9 const char * short_str
= "abcdefghijklmnopqrstuvwxyz";
10 const char * long_str
= "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
14 void stringseq_time_test (CORBA::ULong num_loops
, bool use_long_str
)
16 ACE_High_Res_Timer timer
;
22 seqs
.first_str
.length(0);
23 seqs
.second_str
.length(0);
28 for (CORBA::ULong idx
= 0; idx
< num_loops
; ++idx
)
30 str_len
= seqs
.first_str
.length();
31 seqs
.first_str
.length(str_len
+ 1);
32 seqs
.first_str
[str_len
] = use_long_str
? long_str
: short_str
;
36 timer
.elapsed_time(time
);
41 ACE_TEXT("1, 0, 0, %u, %s, %Q\n"),
43 use_long_str
? ACE_TEXT("long"): ACE_TEXT("short"),
49 ACE_TEXT("String sequence (%u, %s) = %Q ns\n"),
51 use_long_str
? ACE_TEXT("long"): ACE_TEXT("short"),
57 void seqstrseq_time_test (CORBA::ULong num_seq_loops
,
58 CORBA::ULong num_string_loops
,
61 ACE_High_Res_Timer timer
;
67 Sequence_Str_Sequences seqs
;
68 seqs
.seq_str_seq
.length(0);
73 for (CORBA::ULong seq_idx
= 0; seq_idx
< num_seq_loops
; ++seq_idx
)
75 sss_len
= seqs
.seq_str_seq
.length();
76 seqs
.seq_str_seq
.length(sss_len
+ 1);
77 Str_Sequences
& strs
= seqs
.seq_str_seq
[sss_len
];
78 //strs.first_str.length(0);
79 for (CORBA::ULong str_idx
= 0; str_idx
< num_string_loops
; ++str_idx
)
81 str_len
= strs
.second_str
.length();
82 strs
.second_str
.length(str_len
+ 1);
83 strs
.second_str
[str_len
] = use_long_str
? long_str
: short_str
;
88 timer
.elapsed_time(time
);
93 ACE_TEXT("2, 0, %u, %u, %s, %Q\n"),
96 use_long_str
? ACE_TEXT("long"): ACE_TEXT("short"),
102 ACE_TEXT("Sequence of string seq (%u, %u, %s) = %Q ns\n"),
105 use_long_str
? ACE_TEXT("long"): ACE_TEXT("short"),
111 void big_time_test (CORBA::ULong num_list_loops
,
112 CORBA::ULong num_seq_loops
,
113 CORBA::ULong num_string_loops
,
116 ACE_High_Res_Timer timer
;
119 Seq_Structs big_list
;
120 big_list
.seq
.length(0);
122 CORBA::ULong big_len
;
123 CORBA::ULong red_len
;
124 CORBA::ULong sss_len
;
125 CORBA::ULong str_len
;
130 for (CORBA::ULong list_idx
= 0; list_idx
< num_list_loops
; ++list_idx
)
132 big_len
= big_list
.seq
.length();
133 big_list
.seq
.length(big_len
+ 1);
134 Biglist_Struct
& list
= big_list
.seq
[big_len
];
136 for (CORBA::ULong seq_idx
= 0; seq_idx
< num_seq_loops
; ++seq_idx
)
138 red_len
= list
.red_seqs
.length();
139 list
.red_seqs
.length(red_len
+ 1);
141 Sequence_Str_Sequences
& sss
= list
.red_seqs
[red_len
];
143 sss_len
= sss
.seq_str_seq
.length();
144 sss
.seq_str_seq
.length(sss_len
+ 1);
146 Str_Sequences
& strs
= sss
.seq_str_seq
[sss_len
];
147 for (CORBA::ULong str_idx
= 0; str_idx
< num_string_loops
; ++str_idx
)
149 str_len
= strs
.second_str
.length();
150 strs
.second_str
.length(str_len
+ 1);
151 strs
.second_str
[str_len
] = use_long_str
? long_str
: short_str
;
153 str_len
= list
.strs
.first_str
.length();
154 list
.strs
.first_str
.length(str_len
+ 1);
155 list
.strs
.first_str
[str_len
] = use_long_str
? long_str
: short_str
;
160 } // end of list loop
163 timer
.elapsed_time(time
);
168 ACE_TEXT("3, %u, %u, %u, %s, %Q\n"),
172 use_long_str
? ACE_TEXT("long"): ACE_TEXT("short"),
178 ACE_TEXT("Big list test(%u, %u, %u, %s) = %Q ns\n"),
182 use_long_str
? ACE_TEXT("long"): ACE_TEXT("short"),
188 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
191 if (argc
> 1 && ACE_OS::strcasecmp (argv
[1],ACE_TEXT("-csv")) == 0)
196 stringseq_time_test(100, false);
197 stringseq_time_test(1000, false);
199 stringseq_time_test(100, true);
200 stringseq_time_test(1000, true);
203 seqstrseq_time_test(100, 1, false);
204 seqstrseq_time_test(100, 10, false);
205 seqstrseq_time_test(1000, 10, false);
207 seqstrseq_time_test(100, 1, true);
208 seqstrseq_time_test(100, 10, true);
209 seqstrseq_time_test(1000, 10, true);
212 big_time_test(10, 1, 10, false);
213 big_time_test(10, 1, 10, false);
214 big_time_test(10, 10, 10, false);
215 big_time_test(100, 1, 10, false);
217 big_time_test(10, 1, 10, true);
218 big_time_test(10, 1, 10, true);
219 big_time_test(10, 10, 10, true);
220 big_time_test(100, 1, 10, true);
222 catch (const CORBA::Exception
&ex
)
224 ex
._tao_print_exception ("MAIN: Unexpected CORBA exception caught:");