+#ifdef TIME_BENCH
+static void smx_ctx_raw_runall_serial(xbt_dynar_t processes)
+{
+ smx_process_t process;
+ unsigned int cursor;
+
+ double elapsed = 0;
+ double tmax = 0;
+ unsigned long num_proc = xbt_dynar_length(processes);
+ unsigned int t=0;
+ unsigned int data_size = (num_proc / NUM_THREADS) + ((num_proc % NUM_THREADS) ? 1 : 0);
+
+ ssr_count++;
+ time_thread_ssr[0] = 0;
+ xbt_dynar_foreach(processes, cursor, process) {
+ XBT_DEBUG("Schedule item %u of %lu",cursor,xbt_dynar_length(processes));
+ if(cursor >= t * data_size + data_size){
+ if(time_thread_ssr[t] > tmax)
+ tmax = time_thread_ssr[t];
+ t++;
+ time_thread_ssr[t] = 0;
+ }
+
+ if(new_sr){
+ ((smx_ctx_raw_t)process->context)->thread = t;
+ time_thread_sr[t] = 0;
+ }
+
+ xbt_os_timer_start(timer);
+ smx_ctx_raw_resume(process);
+ xbt_os_timer_stop(timer);
+ elapsed = xbt_os_timer_elapsed(timer);
+ time_thread_ssr[t] += elapsed;
+ time_thread_sr[((smx_ctx_raw_t)process->context)->thread] += elapsed;
+ }
+
+ if(new_sr)
+ new_sr = FALSE;
+
+ if(time_thread_ssr[t] > tmax)
+ tmax = time_thread_ssr[t];
+
+ for(cursor=0; cursor <= t; cursor++){
+ XBT_VERB("Time SSR thread %u = %lf (max %lf)", cursor, time_thread_ssr[cursor], tmax);
+ time_wasted_ssr += tmax - time_thread_ssr[cursor];
+ }
+
+ xbt_dynar_reset(processes);
+}
+
+void smx_ctx_raw_new_sr(void);
+void smx_ctx_raw_new_sr(void)
+{
+ int i;
+ double tmax = 0;
+ new_sr = TRUE;
+ sr_count++;
+ for(i=0; i < NUM_THREADS; i++){
+ if(time_thread_sr[i] > tmax)
+ tmax = time_thread_sr[i];
+ }
+
+ for(i=0; i < NUM_THREADS; i++){
+ XBT_VERB("Time SR thread %u = %lf (max %lf)", i, time_thread_sr[i], tmax);
+ time_wasted_sr += tmax - time_thread_sr[i];
+ }