#include "ACEXML/common/XML_Util.h"
#include "ace/OS_main.h"
#include "ace/Time_Value.h"
#include "ace/OS_NS_sys_time.h"
#include "ace/Log_Msg.h"
Include dependency graph for test.cpp:
Go to the source code of this file.
Functions | |
bool | is_escaped (const ACEXML_String &s) |
int | run_tests (ACEXML_String test_strings[NUM_TEST_STRS], int iterations) |
int | ACE_TMAIN (int, ACE_TCHAR *[]) |
Variables | |
const int | MAX_ITERATIONS = 100 * 1000 |
const int | NUM_TEST_STRS = 6 |
|
Definition at line 84 of file test.cpp. References ACE_DEBUG, ACE_TEXT, ACEXML_String, LM_DEBUG, MAX_ITERATIONS, NUM_TEST_STRS, and run_tests().
00085 { 00086 ACEXML_String test_strings[NUM_TEST_STRS] = { 00087 ACE_TEXT("\"xxxxx\"xxxxxxxx xx\"xxxxxx xxxxxx\"xxxxxxxxxx xxxxxxxx\"xxxxxx\""), 00088 ACE_TEXT("'xxxxx\'xxxxxxxx' xxxxxxxx xx'xxxxxxxx'xxxxxx xxxxxxx'xxxxxxx'"), 00089 ACE_TEXT("&xxxx&xxxxxxxxx &xxxxxxxx xxxxx&xxxxxxxxxxx xxxx&xxxxxxxxxx&"), 00090 ACE_TEXT(">xx>xxxxxxxxxxx >xxxxxxxx xxxxx>xxxxxxxxxxx xxxxx>xxxxxxxxx>"), 00091 ACE_TEXT("<xxxxx<xxxxxxxx xxxxxxxx <xxxxxxxxxxxxxxx<x xxxxxxxxxxxxxx<"), 00092 ACE_TEXT("&xxxx\"xxxxxxx&xx xxx'xxxxx xx<xxxxxxx>xxxxxxx xx\"xxxxxxxxxxxx>"), 00093 }; 00094 00095 if (run_tests(test_strings, MAX_ITERATIONS) != 0) 00096 return 1; 00097 00098 ACE_DEBUG((LM_DEBUG, "Rerun tests with larger strings\n")); 00099 for (int i = 0; i < NUM_TEST_STRS; ++i) 00100 { 00101 for (int j = 0; j < 5; ++j) 00102 { 00103 test_strings[i] += test_strings[i]; 00104 } 00105 } 00106 00107 if (run_tests(test_strings, MAX_ITERATIONS / 10) != 0) 00108 return 1; 00109 00110 return 0; 00111 } |
|
Definition at line 14 of file test.cpp. References ACE_TEXT, and ACEXML_String. Referenced by run_tests().
|
|
Definition at line 23 of file test.cpp. References ACE_DEBUG, ACE_ERROR, ACEXML_escape_string(), ACEXML_String, ACE_OS::gettimeofday(), is_escaped(), LM_DEBUG, LM_ERROR, and NUM_TEST_STRS. Referenced by ACE_TMAIN().
00024 { 00025 // Test 1 - Escape the strings using a new temporary string each iteration. 00026 ACE_Time_Value start = ACE_OS::gettimeofday(); 00027 int i = 0; 00028 for (i = 0; i < iterations; ++i) 00029 { 00030 ACEXML_String tmp = ACEXML_escape_string(test_strings[i % NUM_TEST_STRS]); 00031 if (! is_escaped(tmp)) 00032 { 00033 ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n")); 00034 return 1; 00035 } 00036 } 00037 ACE_DEBUG((LM_DEBUG, "Test1 took %dms\n", (ACE_OS::gettimeofday() - start).msec())); 00038 00039 // Test 2 - Escape the strings using a shared temporary string. This shouldn't 00040 // be any faster than Test 1 as long as the compiler has return value optimization. 00041 ACEXML_String tmp; 00042 start = ACE_OS::gettimeofday(); 00043 for (i = 0; i < iterations; ++i) 00044 { 00045 tmp = ACEXML_escape_string(test_strings[i % NUM_TEST_STRS]); 00046 if (! is_escaped(tmp)) 00047 { 00048 ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n")); 00049 return 1; 00050 } 00051 } 00052 ACE_DEBUG((LM_DEBUG, "Test2 took %dms\n", (ACE_OS::gettimeofday() - start).msec())); 00053 00054 // Test 3 - Escape the strings using a shared temporary string. This time, we use 00055 // the alternate form of ACEXML_escape_string() so that our temporary buffer is reused. 00056 tmp.clear(1); 00057 start = ACE_OS::gettimeofday(); 00058 for (i = 0; i < iterations; ++i) 00059 { 00060 ACEXML_escape_string(test_strings[i % NUM_TEST_STRS], tmp); 00061 if (! is_escaped(tmp)) 00062 { 00063 ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n")); 00064 return 1; 00065 } 00066 } 00067 ACE_DEBUG((LM_DEBUG, "Test3 took %dms\n", (ACE_OS::gettimeofday() - start).msec())); 00068 00069 // Test 4 - Same as Test 3, except that the tmp buffer shouldn't have to resize. 00070 start = ACE_OS::gettimeofday(); 00071 for (i = 0; i < iterations; ++i) 00072 { 00073 ACEXML_escape_string(test_strings[i % NUM_TEST_STRS], tmp); 00074 if (! is_escaped(tmp)) 00075 { 00076 ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n")); 00077 return 1; 00078 } 00079 } 00080 ACE_DEBUG((LM_DEBUG, "Test4 took %dms\n", (ACE_OS::gettimeofday() - start).msec())); 00081 return 0; 00082 } |
|
Definition at line 11 of file test.cpp. Referenced by ACE_TMAIN(). |
|
Definition at line 12 of file test.cpp. Referenced by ACE_TMAIN(), and run_tests(). |