MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_ticketlock_perf

Function test_ticketlock_perf

dpdk/app/test/test_ticketlock.c:130–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130static int
131test_ticketlock_perf(void)
132{
133 unsigned int i;
134 uint64_t tcount = 0;
135 uint64_t total_time = 0;
136 int lock = 0;
137 const unsigned int lcore = rte_lcore_id();
138
139 printf("\nTest with no lock on single core...\n");
140 load_loop_fn(&lock);
141 printf("Core [%u] cost time = %"PRIu64" us\n", lcore, time_cost[lcore]);
142 memset(lcore_count, 0, sizeof(lcore_count));
143 memset(time_cost, 0, sizeof(time_cost));
144
145 printf("\nTest with lock on single core...\n");
146 lock = 1;
147 load_loop_fn(&lock);
148 printf("Core [%u] cost time = %"PRIu64" us\n", lcore, time_cost[lcore]);
149 memset(lcore_count, 0, sizeof(lcore_count));
150 memset(time_cost, 0, sizeof(time_cost));
151
152 lcount = 0;
153 printf("\nTest with lock on %u cores...\n", rte_lcore_count());
154
155 /* Clear synchro and start workers */
156 __atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
157 rte_eal_mp_remote_launch(load_loop_fn, &lock, SKIP_MAIN);
158
159 /* start synchro and launch test on main */
160 __atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
161 load_loop_fn(&lock);
162
163 rte_eal_mp_wait_lcore();
164
165 RTE_LCORE_FOREACH(i) {
166 printf("Core [%u] cost time = %"PRIu64" us\n", i, time_cost[i]);
167 tcount += lcore_count[i];
168 total_time += time_cost[i];
169 }
170
171 if (tcount != lcount)
172 return -1;
173
174 printf("Total cost time = %"PRIu64" us\n", total_time);
175
176 return 0;
177}
178
179/*
180 * Use rte_ticketlock_trylock() to trylock a ticketlock object,

Callers 1

test_ticketlockFunction · 0.85

Calls 7

rte_lcore_idFunction · 0.85
memsetFunction · 0.85
rte_lcore_countFunction · 0.85
rte_eal_mp_remote_launchFunction · 0.85
rte_eal_mp_wait_lcoreFunction · 0.85
load_loop_fnFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected