@@ -215,35 +215,46 @@ int main(int argc, char** argv)
215215 assert (vm.has_remote ());
216216
217217 /* Measure call overhead */
218+ uint64_t do_nothing_addr = 0x0 ;
219+ uint64_t do_calculation_addr = 0x0 ;
218220 auto do_it = callback_address.find (" do_nothing" );
219221 if (do_it == callback_address.end ()) {
220- fprintf (stderr, " Error: no do_nothing() in guest\n " );
221- exit (1 );
222+ do_nothing_addr = master_vm.address_of (" do_nothing" );
223+ if (do_nothing_addr == 0x0 ) {
224+ fprintf (stderr, " Error: no do_nothing() in guest\n " );
225+ exit (1 );
226+ }
227+ } else {
228+ do_nothing_addr = do_it->second ;
222229 }
223230 auto calc_it = callback_address.find (" do_calculation" );
224231 if (calc_it == callback_address.end ()) {
225- fprintf (stderr, " Error: no do_calculation() in guest\n " );
226- exit (1 );
232+ do_calculation_addr = master_vm.address_of (" do_calculation" );
233+ if (do_calculation_addr == 0x0 ) {
234+ fprintf (stderr, " Error: no do_calculation() in guest\n " );
235+ exit (1 );
236+ }
237+ } else {
238+ do_calculation_addr = calc_it->second ;
227239 }
228- auto call_overhead = timed_action ([&] {
229- for (int i = 0 ; i < 100 ; i++)
230- vm.vmcall (do_it->second , 5 .0f , 21 );
231- }) / 100.0 ;
232- printf (" Call overhead: %.2fus\n " , call_overhead * 1e6 );
240+ TimedResult call_overhead = timed_action (1000 , [&] {
241+ vm.vmcall (do_nothing_addr, 5 .0f , 21 );
242+ });
243+ printf (" Call overhead: %.2fus\n " , call_overhead.median * 1e6 );
233244
234245 /* Call 'do_calculation' with 21 as argument */
235- printf (" Calling do_calculation() @ 0x%lX\n " , calc_it-> second );
246+ printf (" Calling do_calculation() @ 0x%lX\n " , do_calculation_addr );
236247 for (int i = 0 ; i < 50 ; i++)
237- vm.vmcall (calc_it-> second , 21 );
248+ vm.vmcall (do_calculation_addr , 21 );
238249 TimedResult fork_tdiff = timed_action (15000 , [&] {
239- vm.vmcall (calc_it-> second , 21 );
250+ vm.vmcall (do_calculation_addr , 21 );
240251 });
241252 if (vm.remote_connection_count () < 15000 ) {
242253 fprintf (stderr, " Error: only %u remote connections were made, expected 500\n " ,
243254 vm.remote_connection_count ());
244255 exit (1 );
245256 }
246- fork_tdiff -= call_overhead;
257+ fork_tdiff -= call_overhead. median ;
247258 printf (" * Remote call time: avg %.2fus med %.2fus p50 %.2fus p90 %.2fus p99 %.2fus min %.2fus max %.2fus\n " ,
248259 fork_tdiff.average * 1e6 , fork_tdiff.median * 1e6 ,
249260 fork_tdiff.p50 * 1e6 , fork_tdiff.p90 * 1e6 ,
0 commit comments