add timing

by shenyouren
This commit is contained in:
WangRunji 2019-04-21 17:28:06 +08:00
parent 5d9b8e4fa3
commit ad98a1698e
3 changed files with 22 additions and 0 deletions

@ -10,6 +10,8 @@ enclave {
/* define ECALLs here. */
public int libos_boot([in, string] const char* executable_path, [user_check] const char** argv);
public int libos_run(void);
/* This is only for debug usage */
public int dummy_ecall(void);
};
untrusted {

@ -35,6 +35,10 @@ pub extern "C" fn libos_run() -> i32 {
.unwrap_or(EXIT_STATUS_INTERNAL_ERROR)
}
#[no_mangle]
pub extern "C" fn dummy_ecall() -> i32 {
0
}
// Use 127 as a special value to indicate internal error from libos, not from
// user programs, although it is completely ok for a user program to return 127.
const EXIT_STATUS_INTERNAL_ERROR: i32 = 127;

@ -213,6 +213,9 @@ void ocall_sync(void) {
/* Application entry */
int SGX_CDECL main(int argc, const char *argv[])
{
struct timeval startup, libosready, appdie;
gettimeofday(&startup, NULL);
sgx_status_t sgx_ret = SGX_SUCCESS;
int status = 0;
uint32_t sealed_log_size = 1024;
@ -238,9 +241,22 @@ int SGX_CDECL main(int argc, const char *argv[])
print_error_message(sgx_ret);
return status;
}
// First ecall do a lot initializations.
// Count it as startup time.
dummy_ecall(global_eid, &status);
gettimeofday(&libosready, NULL);
status = wait_all_tasks();
gettimeofday(&appdie, NULL);
uint64_t libos_startup_time, app_runtime;
libos_startup_time = (libosready.tv_sec - startup.tv_sec) * 1000000 + (libosready.tv_usec - startup.tv_usec);
app_runtime = (appdie.tv_sec - libosready.tv_sec) * 1000000 + (appdie.tv_usec - libosready.tv_usec);
printf("LibOS startup time: %d microseconds\n", libos_startup_time);
printf("Apps running time: %d microseconds\n", app_runtime);
/* Destroy the enclave */
sgx_destroy_enclave(global_eid);