5
#include <orbit/orbit.h>
11
static double bogomark = 0.0;
12
static double elapsed_time;
18
#define ELEMS (sizeof (tc) / sizeof (tc[0]))
19
CORBA_TypeCode tc[] = {
21
TC_CORBA_sequence_CORBA_octet,
24
TC_CORBA_sequence_CORBA_string,
27
gpointer data [ELEMS];
28
const char *test_string = "This is a sample string, for dupping";
30
fprintf (stderr, "Testing copy...\n");
32
for (i = 0; i < ELEMS; i++) {
33
data [i] = ORBit_dynany_new_default (tc [i]);
35
g_timer_reset (timer);
36
for (j = 0; j < 1000; j++) {
37
gpointer foo = ORBit_copy_value (data [i], tc [i]);
40
elapsed_time = g_timer_elapsed (timer, NULL);
41
bogomark += elapsed_time;
42
fprintf (stderr, " copy %20s : %g(ms)\n",
43
tc[i]->repo_id == NULL ? "(null)" : tc[i]->repo_id,
47
fprintf (stderr, "Testing strdup ...\n");
49
g_timer_reset (timer);
51
for (i = 0; i < 1000; i++) {
52
char *str = CORBA_string_dup (test_string);
55
elapsed_time = g_timer_elapsed (timer, NULL);
56
bogomark += elapsed_time;
57
fprintf (stderr, " strdup : %g(ms)\n", elapsed_time);
60
static PortableServer_POA
61
create_mult_id_poa (CORBA_Environment *ev)
63
PortableServer_POA rootpoa;
64
PortableServer_POA retval;
65
CORBA_PolicyList *policies;
67
rootpoa = (PortableServer_POA)
68
CORBA_ORB_resolve_initial_references (orb, "RootPOA", ev);
69
g_assert (ev->_major == CORBA_NO_EXCEPTION);
71
policies = CORBA_PolicyList__alloc ();
72
policies->_maximum = 1;
73
policies->_length = 1;
74
policies->_buffer = CORBA_PolicyList_allocbuf (1);
75
CORBA_sequence_set_release (policies, CORBA_TRUE);
77
policies->_buffer[0] = (CORBA_Policy)
78
PortableServer_POA_create_id_uniqueness_policy (
80
PortableServer_MULTIPLE_ID,
82
g_assert (ev->_major == CORBA_NO_EXCEPTION);
84
retval = PortableServer_POA_create_POA (rootpoa, "Multiple Id POA",
86
g_assert (ev->_major == CORBA_NO_EXCEPTION);
88
CORBA_Policy_destroy (policies->_buffer[0], ev);
89
CORBA_free (policies);
91
g_assert (ev->_major == CORBA_NO_EXCEPTION);
93
CORBA_Object_release ((CORBA_Object) rootpoa, ev);
95
g_assert (ev->_major == CORBA_NO_EXCEPTION);
100
PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL };
101
POA_Test__epv test_epv = { NULL, NULL };
102
POA_Test__vepv test_vepv = { &base_epv, &test_epv };
103
POA_Test test_servant = { NULL, &test_vepv };
106
test_activation (void)
108
CORBA_Environment env;
109
PortableServer_POA poa;
110
GSList *objids = NULL, *l;
113
fprintf (stderr, "Testing object activation...\n");
115
CORBA_exception_init (&env);
117
POA_Test__init (&test_servant, &env);
119
poa = create_mult_id_poa (&env);
121
g_assert (env._major == CORBA_NO_EXCEPTION);
123
g_timer_reset (timer);
125
for (i = 0; i < 1000; i++) {
126
PortableServer_ObjectId *objid;
128
objid = PortableServer_POA_activate_object (poa, &test_servant, &env);
129
g_assert (env._major == CORBA_NO_EXCEPTION);
131
objids = g_slist_append (objids, objid);
134
elapsed_time = g_timer_elapsed (timer, NULL);
135
bogomark += elapsed_time;
136
fprintf (stderr, " activation : %g(ms)\n", elapsed_time);
138
g_timer_reset (timer);
140
for (l = objids; l; l = l->next) {
141
PortableServer_POA_deactivate_object (poa, l->data, &env);
142
g_assert (env._major == CORBA_NO_EXCEPTION);
145
elapsed_time = g_timer_elapsed (timer, NULL);
146
bogomark += elapsed_time;
147
fprintf (stderr, " de-activation : %g(ms)\n", elapsed_time);
149
for (l = objids; l; l = l->next)
150
CORBA_free (l->data);
151
g_slist_free (objids);
153
POA_Test__fini (&test_servant, &env);
155
CORBA_Object_release ((CORBA_Object) poa, &env);
156
g_assert (env._major == CORBA_NO_EXCEPTION);
158
CORBA_exception_free (&env);
162
main (int argc, char *argv[])
164
CORBA_Environment ev;
168
CORBA_exception_init (&ev);
170
timer = g_timer_new ();
171
g_timer_start (timer);
173
g_timer_reset (timer);
174
orb = CORBA_ORB_init (&argc, argv, "orbit-local-orb", &ev);
175
g_assert (ev._major == CORBA_NO_EXCEPTION);
176
fprintf (stderr, "ORB: init took %g(ms)\n",
177
(elapsed_time = g_timer_elapsed (timer, NULL)) * 1000.0);
178
bogomark += elapsed_time;
184
g_timer_reset (timer);
185
CORBA_ORB_destroy (orb, &ev);
186
g_assert (ev._major == CORBA_NO_EXCEPTION);
187
fprintf (stderr, "ORB: destroy took %g(ms)\n",
188
(elapsed_time = g_timer_elapsed (timer, NULL)) * 1000.0);
189
bogomark += elapsed_time;
190
g_timer_reset (timer);
192
CORBA_Object_release ((CORBA_Object) orb, &ev);
193
g_assert (ev._major == CORBA_NO_EXCEPTION);
195
g_timer_destroy (timer);
197
fprintf (stderr, "Overall bogomark %g\n", 1000.0 / bogomark);