wall time distinctly.
Windows section isn't test.
Signed-off-by: Guillaume Serrière <guillaume.serriere@esial.net>
int main(int argc, char *argv[])
{
#ifdef BENCH_THIS_CODE
- xbt_os_timer_t timer = xbt_os_timer_new();
+ xbt_os_cputimer_t timer = xbt_os_timer_new();
#endif
MSG_init(&argc, argv);
MSG_launch_application(application_file);
#ifdef BENCH_THIS_CODE
- xbt_os_timer_start(timer);
+ xbt_os_cputimer_start(timer);
#endif
msg_error_t res = MSG_main();
#ifdef BENCH_THIS_CODE
- xbt_os_timer_stop(timer);
+ xbt_os_cputimer_stop(timer);
#endif
XBT_CRITICAL("Simulated time: %g", MSG_get_clock());
reclaimed = xbt_dynar_new(sizeof(bcast_task_t),xbt_free_ref);
xbt_dynar_t done = NULL;
- xbt_os_timer_start(timer);
+ xbt_os_cputimer_start(timer);
send_one(0,SD_workstation_get_number());
do {
if (done != NULL && !xbt_dynar_is_empty(done)) {
}
done=SD_simulate(-1);
} while(!xbt_dynar_is_empty(done));
- xbt_os_timer_stop(timer);
+ xbt_os_cputimer_stop(timer);
printf("exec_time:%lf\n", xbt_os_timer_elapsed(timer) );
xbt_dynar_free(&done);
typedef struct s_xbt_os_timer *xbt_os_timer_t;
XBT_PUBLIC(xbt_os_timer_t) xbt_os_timer_new(void);
XBT_PUBLIC(void) xbt_os_timer_free(xbt_os_timer_t timer);
-XBT_PUBLIC(void) xbt_os_timer_start(xbt_os_timer_t timer);
-XBT_PUBLIC(void) xbt_os_timer_resume(xbt_os_timer_t timer);
-XBT_PUBLIC(void) xbt_os_timer_stop(xbt_os_timer_t timer);
XBT_PUBLIC(double) xbt_os_timer_elapsed(xbt_os_timer_t timer);
+
+XBT_PUBLIC(void) xbt_os_walltimer_start(xbt_os_timer_t timer);
+XBT_PUBLIC(void) xbt_os_walltimer_resume(xbt_os_timer_t timer);
+XBT_PUBLIC(void) xbt_os_walltimer_stop(xbt_os_timer_t timer);
+
+XBT_PUBLIC(void) xbt_os_cputimer_start(xbt_os_timer_t timer);
+XBT_PUBLIC(void) xbt_os_cputimer_resume(xbt_os_timer_t timer);
+XBT_PUBLIC(void) xbt_os_cputimer_stop(xbt_os_timer_t timer);
+
+XBT_PUBLIC(void) xbt_os_threadtimer_start(xbt_os_timer_t timer);
+XBT_PUBLIC(void) xbt_os_threadtimer_resume(xbt_os_timer_t timer);
+XBT_PUBLIC(void) xbt_os_threadtimer_stop(xbt_os_timer_t timer);
#endif
xbt_os_timer_t global_timer = xbt_os_timer_new();
xbt_os_timer_t timer = xbt_os_timer_new();
- xbt_os_timer_start(global_timer);
+ xbt_os_walltimer_start(global_timer);
#ifdef MC_DEBUG
- xbt_os_timer_start(timer);
+ xbt_os_walltimer_start(timer);
#endif
/* Compare number of processes */
if(s1->nb_processes != s2->nb_processes){
#ifdef MC_DEBUG
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
mc_comp_times->nb_processes_comparison_time = xbt_os_timer_elapsed(timer);
XBT_DEBUG("Different number of processes : %d - %d", s1->nb_processes, s2->nb_processes);
errors++;
#endif
xbt_os_timer_free(timer);
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
xbt_os_timer_free(global_timer);
}
#ifdef MC_DEBUG
- xbt_os_timer_start(timer);
+ xbt_os_walltimer_start(timer);
#endif
/* Compare number of bytes used in each heap */
if(s1->heap_bytes_used != s2->heap_bytes_used){
#ifdef MC_DEBUG
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
mc_comp_times->bytes_used_comparison_time = xbt_os_timer_elapsed(timer);
XBT_DEBUG("Different number of bytes used in each heap : %zu - %zu", s1->heap_bytes_used, s2->heap_bytes_used);
errors++;
#endif
xbt_os_timer_free(timer);
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
xbt_os_timer_free(global_timer);
#endif
}else{
#ifdef MC_DEBUG
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
#endif
}
#ifdef MC_DEBUG
- xbt_os_timer_start(timer);
+ xbt_os_walltimer_start(timer);
#endif
/* Compare size of stacks */
if(size_used1 != size_used2){
#ifdef MC_DEBUG
if(is_diff == 0){
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
mc_comp_times->stacks_sizes_comparison_time = xbt_os_timer_elapsed(timer);
}
XBT_DEBUG("Different size used in stacks : %zu - %zu", size_used1, size_used2);
#endif
xbt_os_timer_free(timer);
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
xbt_os_timer_free(global_timer);
#ifdef MC_DEBUG
if(is_diff == 0)
- xbt_os_timer_stop(timer);
- xbt_os_timer_start(timer);
+ xbt_os_walltimer_stop(timer);
+ xbt_os_walltimer_start(timer);
#endif
/* Compare hash of global variables */
if(s1->hash_global != NULL && s2->hash_global != NULL){
if(strcmp(s1->hash_global, s2->hash_global) != 0){
#ifdef MC_DEBUG
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
mc_comp_times->hash_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
XBT_DEBUG("Different hash of global variables : %s - %s", s1->hash_global, s2->hash_global);
errors++;
#endif
xbt_os_timer_free(timer);
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
xbt_os_timer_free(global_timer);
}
#ifdef MC_DEBUG
- xbt_os_timer_start(timer);
+ xbt_os_walltimer_start(timer);
#endif
/* Compare hash of local variables */
if(s1->hash_local != NULL && s2->hash_local != NULL){
if(strcmp(s1->hash_local, s2->hash_local) != 0){
#ifdef MC_DEBUG
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
mc_comp_times->hash_local_variables_comparison_time = xbt_os_timer_elapsed(timer);
XBT_DEBUG("Different hash of local variables : %s - %s", s1->hash_local, s2->hash_local);
errors++;
#endif
xbt_os_timer_free(timer);
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
xbt_os_timer_free(global_timer);
}
#ifdef MC_DEBUG
- xbt_os_timer_start(timer);
+ xbt_os_walltimer_start(timer);
#endif
/* Init heap information used in heap comparison algorithm */
is_diff = compare_global_variables(2, s1->regions[2]->data, s2->regions[2]->data);
if(is_diff != 0){
#ifdef MC_DEBUG
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
mc_comp_times->binary_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
XBT_DEBUG("Different global variables in binary");
errors++;
reset_heap_information();
xbt_os_timer_free(timer);
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
xbt_os_timer_free(global_timer);
#ifdef MC_DEBUG
if(is_diff == 0)
- xbt_os_timer_stop(timer);
- xbt_os_timer_start(timer);
+ xbt_os_walltimer_stop(timer);
+ xbt_os_walltimer_start(timer);
#endif
/* Compare libsimgrid global variables */
is_diff = compare_global_variables(1, s1->regions[1]->data, s2->regions[1]->data);
if(is_diff != 0){
#ifdef MC_DEBUG
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
mc_comp_times->libsimgrid_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
XBT_DEBUG("Different global variables in libsimgrid");
errors++;
reset_heap_information();
xbt_os_timer_free(timer);
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
xbt_os_timer_free(global_timer);
#ifdef MC_DEBUG
if(is_diff == 0)
- xbt_os_timer_stop(timer);
- xbt_os_timer_start(timer);
+ xbt_os_walltimer_stop(timer);
+ xbt_os_walltimer_start(timer);
#endif
/* Stacks comparison */
if(diff_local > 0){
#ifdef MC_DEBUG
if(is_diff == 0){
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
mc_comp_times->stacks_comparison_time = xbt_os_timer_elapsed(timer);
}
XBT_DEBUG("Different local variables between stacks %d", cursor + 1);
reset_heap_information();
xbt_os_timer_free(timer);
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
xbt_os_timer_free(global_timer);
}
#ifdef MC_DEBUG
- xbt_os_timer_start(timer);
+ xbt_os_walltimer_start(timer);
#endif
/* Compare heap */
if(mmalloc_compare_heap((xbt_mheap_t)s1->regions[0]->data, (xbt_mheap_t)s2->regions[0]->data)){
#ifdef MC_DEBUG
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
mc_comp_times->heap_comparison_time = xbt_os_timer_elapsed(timer);
XBT_DEBUG("Different heap (mmalloc_compare)");
errors++;
#endif
reset_heap_information();
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
xbt_os_timer_free(global_timer);
#endif
}else{
#ifdef MC_DEBUG
- xbt_os_timer_stop(timer);
+ xbt_os_walltimer_stop(timer);
#endif
}
xbt_os_timer_free(timer);
#ifdef MC_VERBOSE
- xbt_os_timer_stop(global_timer);
+ xbt_os_walltimer_stop(global_timer);
mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
#endif
time_thread_sr[t] = 0;
}
- xbt_os_timer_start(timer);
+ xbt_os_cputimer_start(timer);
smx_ctx_raw_resume(process);
- xbt_os_timer_stop(timer);
+ xbt_os_cputimer_stop(timer);
elapsed = xbt_os_timer_elapsed(timer);
time_thread_ssr[t] += elapsed;
time_thread_sr[((smx_ctx_raw_t)process->context)->thread] += elapsed;
else {
/* all processes were run, go to the barrier */
XBT_DEBUG("No more processes to run");
+
unsigned long worker_id =
(unsigned long) xbt_os_thread_get_specific(raw_worker_id_key);
+
next_context = (smx_context_t)raw_workers_context[worker_id];
XBT_DEBUG("Restoring worker stack %lu (working threads = %lu)",
worker_id, raw_threads_working);
#ifdef TIME_BENCH_AMDAHL
simix_global->timer_seq = xbt_os_timer_new();
simix_global->timer_par = xbt_os_timer_new();
- xbt_os_timer_start(simix_global->timer_seq);
+ xbt_os_cputimer_start(simix_global->timer_seq);
#endif
simix_global->process_to_run = xbt_dynar_new(sizeof(smx_process_t), NULL);
simix_global->process_that_ran = xbt_dynar_new(sizeof(smx_process_t), NULL);
surf_exit();
#ifdef TIME_BENCH_AMDAHL
- xbt_os_timer_stop(simix_global->timer_seq);
+ xbt_os_cputimer_stop(simix_global->timer_seq);
XBT_INFO("Amdhal timing informations. Sequential time: %lf; Parallel time: %lf",
xbt_os_timer_elapsed(simix_global->timer_seq),
xbt_os_timer_elapsed(simix_global->timer_par));
/* Run all processes that are ready to run, possibly in parallel */
#ifdef TIME_BENCH_AMDAHL
- xbt_os_timer_stop(simix_global->timer_seq);
- xbt_os_timer_resume(simix_global->timer_par);
+ xbt_os_cputimer_stop(simix_global->timer_seq);
+ xbt_os_cputimer_resume(simix_global->timer_par);
#endif
SIMIX_process_runall();
#ifdef TIME_BENCH_AMDAHL
- xbt_os_timer_stop(simix_global->timer_par);
- xbt_os_timer_resume(simix_global->timer_seq);
+ xbt_os_cputimer_stop(simix_global->timer_par);
+ xbt_os_cputimer_resume(simix_global->timer_seq);
#endif
/* Move all killing processes to the end of the list, because killing a process that have an ongoing simcall is a bad idea */
void smpi_bench_begin(void)
{
- xbt_os_timer_start(smpi_process_timer());
+ xbt_os_threadtimer_start(smpi_process_timer());
smpi_current_rank = smpi_process_index();
}
{
xbt_os_timer_t timer = smpi_process_timer();
- xbt_os_timer_stop(timer);
+ xbt_os_threadtimer_stop(timer);
smpi_execute(xbt_os_timer_elapsed(timer));
}
}
// ok, benchmarking this loop is over
- xbt_os_timer_stop(smpi_process_timer());
+ xbt_os_threadtimer_stop(smpi_process_timer());
// update the stats
double sample, n;
free(timer);
}
-void xbt_os_timer_resume(xbt_os_timer_t timer)
+double xbt_os_timer_elapsed(xbt_os_timer_t timer)
{
#ifdef HAVE_POSIX_GETTIME
- timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
-
- timer->elapse.tv_nsec += timer->stop.tv_nsec - timer->start.tv_nsec;
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(timer->start));
-#elif defined(HAVE_GETTIMEOFDAY)
- timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
-
- timer->elapse.tv_usec += timer->stop.tv_usec - timer->start.tv_usec;
- gettimeofday(&(timer->start), NULL);
+ return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec) +
+ ((double) timer->elapse.tv_sec ) +
+ ((((double) timer->stop.tv_nsec) -
+ ((double) timer->start.tv_nsec) + ((double) timer->elapse.tv_nsec )) / 1e9);
+#elif defined(HAVE_GETTIMEOFDAY) || defined(_XBT_WIN32)
+ return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec)
+ + ((double) timer->elapse.tv_sec ) +
+ ((((double) timer->stop.tv_usec) -
+ ((double) timer->start.tv_usec) + ((double) timer->elapse.tv_usec )) / 1000000.0);
#else
- timer->elapse = timer->stop - timer->start;
- timer->start = (unsigned long int) (time(NULL));
+ return (double) timer->stop - (double) timer->start + (double)
+ timer->elapse;
#endif
}
-void xbt_os_timer_start(xbt_os_timer_t timer)
+void xbt_os_walltimer_start(xbt_os_timer_t timer)
{
#ifdef HAVE_POSIX_GETTIME
timer->elapse.tv_sec = 0;
timer->elapse.tv_nsec = 0;
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(timer->start));
+ clock_gettime(CLOCK_REALTIME, &(timer->start));
#elif defined(HAVE_GETTIMEOFDAY)
timer->elapse.tv_sec = 0;
timer->elapse.tv_usec = 0;
gettimeofday(&(timer->start), NULL);
+#elif defined(_XBT_WIN32)
+ timer->elapse.tv_sec = 0;
+ timer->elapse.tv_usec = 0;
+# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
+ struct _timeb tm;
+
+ _ftime(&tm);
+
+ timer->start.tv_sec = tm.time;
+ timer->start.tv_usec = tm.millitm * 1000;
+
+# else
+ FILETIME ft;
+ unsigned __int64 tm;
+
+ GetSystemTimeAsFileTime(&ft);
+ tm = (unsigned __int64) ft.dwHighDateTime << 32;
+ tm |= ft.dwLowDateTime;
+ tm /= 10;
+ tm -= 11644473600000000ULL;
+
+ timer->start.tv_sec = (long) (tm / 1000000L);
+ timer->start.tv_usec = (long) (tm % 1000000L);
+# endif /* windows version checker */
#else
timer->elapse = 0;
timer->start = (unsigned long int) (time(NULL));
#endif
}
-void xbt_os_timer_stop(xbt_os_timer_t timer)
+void xbt_os_walltimer_resume(xbt_os_timer_t timer)
{
#ifdef HAVE_POSIX_GETTIME
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(timer->stop));
+ timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
+
+ timer->elapse.tv_nsec += timer->stop.tv_nsec - timer->start.tv_nsec;
+ clock_gettime(CLOCK_REALTIME, &(timer->start));
#elif defined(HAVE_GETTIMEOFDAY)
- gettimeofday(&(timer->stop), NULL);
+ timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
+ timer->elapse.tv_usec += timer->stop.tv_usec - timer->start.tv_usec;
+ gettimeofday(&(timer->start), NULL);
+#elif defined(_XBT_WIN32)
+ timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
+ timer->elapse.tv_usec += timer->stop.tv_usec - timer->start.tv_usec;
+# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
+ struct _timeb tm;
+
+ _ftime(&tm);
+
+ timer->start.tv_sec = tm.time;
+ timer->start.tv_usec = tm.millitm * 1000;
+
+# else
+ FILETIME ft;
+ unsigned __int64 tm;
+
+ GetSystemTimeAsFileTime(&ft);
+ tm = (unsigned __int64) ft.dwHighDateTime << 32;
+ tm |= ft.dwLowDateTime;
+ tm /= 10;
+ tm -= 11644473600000000ULL;
+
+ timer->start.tv_sec = (long) (tm / 1000000L);
+ timer->start.tv_usec = (long) (tm % 1000000L);
+# endif
#else
- timer->stop = (unsigned long int) (time(NULL));
+ timer->elapse = timer->stop - timer->start;
+ timer->start = (unsigned long int) (time(NULL));
#endif
}
-double xbt_os_timer_elapsed(xbt_os_timer_t timer)
+void xbt_os_walltimer_stop(xbt_os_timer_t timer)
{
#ifdef HAVE_POSIX_GETTIME
- return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec) +
- ((double) timer->elapse.tv_sec ) +
- ((((double) timer->stop.tv_nsec) -
- ((double) timer->start.tv_nsec) + ((double) timer->elapse.tv_nsec )) / 1e9);
+ clock_gettime(CLOCK_REALTIME, &(timer->stop));
#elif defined(HAVE_GETTIMEOFDAY)
- return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec)
- + ((double) timer->elapse.tv_sec ) +
- ((((double) timer->stop.tv_usec) -
- ((double) timer->start.tv_usec) + ((double) timer->elapse.tv_usec )) / 1000000.0);
+ gettimeofday(&(timer->stop), NULL);
+#elif defined(_XBT_WIN32)
+# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
+ struct _timeb tm;
+
+ _ftime(&tm);
+
+ timer->stop.tv_sec = tm.time;
+ timer->stop.tv_usec = tm.millitm * 1000;
+
+# else
+ FILETIME ft;
+ unsigned __int64 tm;
+
+ GetSystemTimeAsFileTime(&ft);
+ tm = (unsigned __int64) ft.dwHighDateTime << 32;
+ tm |= ft.dwLowDateTime;
+ tm /= 10;
+ tm -= 11644473600000000ULL;
+
+ timer->stop.tv_sec = (long) (tm / 1000000L);
+ timer->stop.tv_usec = (long) (tm % 1000000L);
+# endif
#else
- return (double) timer->stop - (double) timer->start + (double)
- timer->elapse;
+ timer->stop = (unsigned long int) (time(NULL));
+#endif
+}
+
+void xbt_os_cputimer_start(xbt_os_timer_t timer)
+{
+#ifdef HAVE_POSIX_GETTIME
+ timer->elapse.tv_sec = 0;
+ timer->elapse.tv_nsec = 0;
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(timer->start));
+#elif defined(_XBT_WIN32)
+ timer->elapse.tv_sec = 0;
+ timer->elapse.tv_nsec = 0;
+# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
+ THROW_UNIMPLEMENTED;
+# else
+ HANDLE h = GetCurrentProcess();
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ GetProcessTimes(h, &creationTime, &exitTime, &kernelTime, &userTime);
+ unsigned __int64 ktm, utm;
+ ktm = (unsigned __int64) kernelTime.dwHighDateTime << 32;
+ ktm |= kernelTime.dwLowDateTime;
+ ktm /= 10;
+ utm = (unsigned __int64) userTime.dwHighDateTime << 32;
+ utm |= userTime.dwLowDateTime;
+ utm /= 10;
+ timer->start.tv_sec = (long) (ktm / 1000000L) + (long) (utm / 1000000L);
+ timer->start.tv_usec = (long) (ktm % 1000000L) + (long) (utm % 1000000L);
+# endif /* windows version checker */
+#endif
+}
+
+void xbt_os_cputimer_resume(xbt_os_timer_t timer)
+{
+#ifdef HAVE_POSIX_GETTIME
+ timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
+ timer->elapse.tv_nsec += timer->stop.tv_nsec - timer->start.tv_nsec;
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(timer->start));
+#elif defined(_XBT_WIN32)
+ timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
+ timer->elapse.tv_nsec += timer->stop.tv_nsec - timer->start.tv_nsec;
+# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
+ THROW_UNIMPLEMENTED;
+# else
+ HANDLE h = GetCurrentProcess();
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ GetProcessTimes(h, &creationTime, &exitTime, &kernelTime, &userTime);
+ unsigned __int64 ktm, utm;
+ ktm = (unsigned __int64) kernelTime.dwHighDateTime << 32;
+ ktm |= kernelTime.dwLowDateTime;
+ ktm /= 10;
+ utm = (unsigned __int64) userTime.dwHighDateTime << 32;
+ utm |= userTime.dwLowDateTime;
+ utm /= 10;
+ timer->start.tv_sec = (long) (ktm / 1000000L) + (long) (utm / 1000000L);
+ timer->start.tv_usec = (long) (ktm % 1000000L) + (long) (utm % 1000000L);
+# endif /* windows version checker */
+
+#endif
+}
+
+void xbt_os_cputimer_stop(xbt_os_timer_t timer)
+{
+#ifdef HAVE_POSIX_GETTIME
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(timer->stop));
+#elif defined(_XBT_WIN32)
+# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
+ THROW_UNIMPLEMENTED;
+# else
+ HANDLE h = GetCurrentProcess();
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ GetProcessTimes(h, &creationTime, &exitTime, &kernelTime, &userTime);
+ unsigned __int64 ktm, utm;
+ ktm = (unsigned __int64) kernelTime.dwHighDateTime << 32;
+ ktm |= kernelTime.dwLowDateTime;
+ ktm /= 10;
+ utm = (unsigned __int64) userTime.dwHighDateTime << 32;
+ utm |= userTime.dwLowDateTime;
+ utm /= 10;
+ timer->stop.tv_sec = (long) (ktm / 1000000L) + (long) (utm / 1000000L);
+ timer->stop.tv_usec = (long) (ktm % 1000000L) + (long) (utm % 1000000L);
+# endif /* windows version checker */
+#endif
+}
+
+void xbt_os_threadtimer_start(xbt_os_timer_t timer)
+{
+#ifdef HAVE_POSIX_GETTIME
+ timer->elapse.tv_sec = 0;
+ timer->elapse.tv_nsec = 0;
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &(timer->start));
+#elif defined(_XBT_WIN32)
+ struct timeval tv;
+# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
+ THROW_UNIMPLEMENTED;
+# else
+ HANDLE h = GetCurrentThread();
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ GetThreadTimes(h, &creationTime, &exitTime, &kernelTime, &userTime);
+ unsigned __int64 ktm, utm;
+ ktm = (unsigned __int64) kernelTime.dwHighDateTime << 32;
+ ktm |= kernelTime.dwLowDateTime;
+ ktm /= 10;
+ utm = (unsigned __int64) userTime.dwHighDateTime << 32;
+ utm |= userTime.dwLowDateTime;
+ utm /= 10;
+ timer->start.tv_sec = (long) (ktm / 1000000L) + (long) (utm / 1000000L);
+ timer->start.tv_usec = (long) (ktm % 1000000L) + (long) (utm % 1000000L);
+# endif /* windows version checker */
+#endif
+}
+
+void xbt_os_threadtimer_resume(xbt_os_timer_t timer)
+{
+#ifdef HAVE_POSIX_GETTIME
+ timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
+ timer->elapse.tv_nsec += timer->stop.tv_nsec - timer->start.tv_nsec;
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &(timer->start));
+#elif defined(_XBT_WIN32)
+ timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;
+ timer->elapse.tv_nsec += timer->stop.tv_nsec - timer->start.tv_nsec;
+# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
+ THROW_UNIMPLEMENTED;
+# else
+ HANDLE h = GetCurrentThread();
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ GetThreadTimes(h, &creationTime, &exitTime, &kernelTime, &userTime);
+ unsigned __int64 ktm, utm;
+ ktm = (unsigned __int64) kernelTime.dwHighDateTime << 32;
+ ktm |= kernelTime.dwLowDateTime;
+ ktm /= 10;
+ utm = (unsigned __int64) userTime.dwHighDateTime << 32;
+ utm |= userTime.dwLowDateTime;
+ utm /= 10;
+ timer->start.tv_sec = (long) (ktm / 1000000L) + (long) (utm / 1000000L);
+ timer->start.tv_usec = (long) (ktm % 1000000L) + (long) (utm % 1000000L);
+# endif /* windows version checker */
+#endif
+}
+
+void xbt_os_threadtimer_stop(xbt_os_timer_t timer)
+{
+#ifdef HAVE_POSIX_GETTIME
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &(timer->stop));
+#elif defined(_XBT_WIN32)
+# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
+ THROW_UNIMPLEMENTED;
+# else
+ HANDLE h = GetCurrentThread();
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ GetThreadTimes(h, &creationTime, &exitTime, &kernelTime, &userTime);
+ unsigned __int64 ktm, utm;
+ ktm = (unsigned __int64) kernelTime.dwHighDateTime << 32;
+ ktm |= kernelTime.dwLowDateTime;
+ ktm /= 10;
+ utm = (unsigned __int64) userTime.dwHighDateTime << 32;
+ utm |= userTime.dwLowDateTime;
+ utm /= 10;
+ timer->stop.tv_sec = (long) (ktm / 1000000L) + (long) (utm / 1000000L);
+ timer->stop.tv_usec = (long) (ktm % 1000000L) + (long) (utm % 1000000L);
+# endif /* windows version checker */
#endif
}
w2 = workstations[j];
printf("%d\tand\t%d\t\t",i,j);
- xbt_os_timer_start(timer);
+ xbt_os_cputimer_start(timer);
SD_route_get_list(w1, w2);
- xbt_os_timer_stop(timer);
+ xbt_os_cputimer_stop(timer);
printf("%lf\n", xbt_os_timer_elapsed(timer) );
SD_init(&argc, argv);
/* creation of the environment, timed */
- xbt_os_timer_start(timer);
+ xbt_os_cputimer_start(timer);
SD_create_environment(argv[1]);
- xbt_os_timer_stop(timer);
+ xbt_os_cputimer_stop(timer);
/* Display the result and exit after cleanup */
printf( "%lf\n", xbt_os_timer_elapsed(timer) );
{
xbt_ex_t e;
TRY {
- xbt_os_timer_start(parse_time);
+ xbt_os_cputimer_start(parse_time);
SD_create_environment(platformFile);
- xbt_os_timer_stop(parse_time);
+ xbt_os_cputimer_stop(parse_time);
}
CATCH(e) {
xbt_die("Error while loading %s: %s", platformFile, e.msg);