Timings*
timings_new (guint scheduled_duration,
	     guint max_duration)
{
	Timings*        this;
	TimingsPrivate* priv;

	// verify the caller is not stupid
	if (scheduled_duration > max_duration)
		return NULL;

	this = g_object_new (TIMINGS_TYPE, NULL);
	if (!this)
		return NULL;

	priv = GET_PRIVATE (this);

	priv->on_screen_timer = g_timer_new ();
	g_timer_stop (priv->on_screen_timer);

	priv->duration_timer = g_timer_new ();
	g_timer_stop (priv->duration_timer);

	priv->paused_timer = g_timer_new ();
	g_timer_stop (priv->paused_timer);

	priv->scheduled_duration = scheduled_duration;
	priv->max_duration       = max_duration;
	priv->is_started         = FALSE;
	priv->is_paused          = FALSE;

	return this;
}
gboolean
timings_stop (Timings* t)
{
	TimingsPrivate* priv;
	gboolean        removed_successfully;

	// sanity checks
	if (!t)
		return FALSE;

	priv = GET_PRIVATE (t);
	if (!priv)
		return FALSE;

	// if we have not been started, return early
	if (!priv->is_started)
	{
		if (g_getenv ("DEBUG"))
			g_print ("\n*** WARNING: Can't stop something, which "
				 "is not started yet!\n");

		return FALSE;
	}

	// get rid of timeouts
	if (!priv->is_paused)
	{
		// remove timeout for normal scheduled duration
		removed_successfully = g_source_remove (priv->timeout_id);
		g_assert (removed_successfully);
	}

	// remove timeout enforcing max. time-limit
	removed_successfully = g_source_remove (priv->max_timeout_id);
	g_assert (removed_successfully);

	// halt all timers
	if (priv->is_paused)
		g_timer_stop (priv->paused_timer);
	else
	{
		g_timer_stop (priv->on_screen_timer);
		g_timer_stop (priv->duration_timer);
	}

	// indicate that we stopped (means also not paused)
	priv->is_started = FALSE;
	priv->is_paused = FALSE;

	// spit out some debugging information
	_debug_output (priv);

	return TRUE;
}
gint
main (gint    argc,
      gchar **argv)
{
	GtkSourceBuffer *source_buffer;
	GtkTextBuffer *text_buffer;
	GtkTextIter iter;
	GTimer *timer;
	gint nb_actions;
	gint i;

	gtk_init (&argc, &argv);

	source_buffer = gtk_source_buffer_new (NULL);
	text_buffer = GTK_TEXT_BUFFER (source_buffer);

	gtk_text_buffer_get_start_iter (text_buffer, &iter);

	for (i = 0; i < NB_LINES; i++)
	{
		gtk_text_buffer_begin_user_action (text_buffer);

		gtk_text_buffer_insert (text_buffer,
					&iter,
					"A line of text to fill the text buffer. Is it long enough?\n",
					-1);

		gtk_text_buffer_end_user_action (text_buffer);
	}

	timer = g_timer_new ();
	nb_actions = test_undo_redo (source_buffer, NB_LINES / 10);
	g_timer_stop (timer);

	g_print ("Undo/Redo %d actions: %lf seconds.\n",
		 nb_actions,
		 g_timer_elapsed (timer, NULL));

	g_timer_start (timer);
	nb_actions = test_undo_redo (source_buffer, NB_LINES);
	g_timer_stop (timer);

	g_print ("Undo/Redo %d actions: %lf seconds.\n",
		 nb_actions,
		 g_timer_elapsed (timer, NULL));

	g_object_unref (source_buffer);
	g_timer_destroy (timer);
	return 0;
}
Example #4
0
void freettcn::example::CGlibPlatformAdaptor::CTimer::Stop()
{
  if (!g_source_remove(_id))
    throw EOperationFailed(E_DATA, "Removing of a timer failed!!!");
  _state = STOPPED;
  g_timer_stop(_timer);
}
Example #5
0
int get_active_frame(topview* t)
{
	gulong microseconds;
	gdouble seconds;
	int fr;
	seconds=g_timer_elapsed(view->timer,&microseconds);
	fr=(int)(seconds/((double)view->frame_length/(double)1000));
	if (fr<view->total_frames)
	{

		if (fr==view->active_frame)
			return 0;
		else
		{
			view->active_frame=fr;
			return 1;
		}
	}
	else
	{
		g_timer_stop(view->timer); 
//		view->Topview->animate=0;
		return 0;
	}

}
Example #6
0
File: main.c Project: tfarago/mgpu
static void
measure_benchmark (const gchar *prefix, BenchmarkFunc func, Benchmark *benchmark)
{
    gdouble time;
    gdouble error;
    gboolean check_error;
    GTimer *timer;
    
    timer = g_timer_new();
    check_error = func (benchmark);
    
    clWaitForEvents (benchmark->num_images, benchmark->read_events);
    g_timer_stop (timer);
    time = g_timer_elapsed (timer, NULL);
    g_timer_destroy(timer);

    error = check_error ? compare_single_multi (benchmark) : 0.0;
    g_print("# %s: total = %fs, time per image = %fs, error = %f\n",
            prefix, time, time / benchmark->num_images, error);

    if (benchmark->settings->do_profile) {
        FILE *fp;
        gchar *filename;

        filename = g_strdup_printf ("%s.clstat", prefix);
        fp = fopen(filename, "w");
        ocl_show_event_info (fp, "nlm", benchmark->num_images, benchmark->events);
        fclose (fp);
        g_free (filename);
    }
}
Example #7
0
/* Detect gesture based on time */
void ramble_time(struct ramble *ramble)
{
	START_FUNC
	struct ramble_point *pt;
	pt=(struct ramble_point *)ramble->end->data;
	if (pt->k) {
		/* TODO:
		 * reset the timer when pointer is near the border */
		if ( (!ramble->end->prev) ||
			(((struct ramble_point *)ramble->end->prev->data)->k!=pt->k) ) {
			if (ramble->timer)
				g_timer_start(ramble->timer);
			else
				ramble->timer=g_timer_new();
		} else if (g_timer_elapsed(ramble->timer, NULL)>=
			(settings_get_double(SETTINGS_RAMBLE_TIMER)/1000.0)) {
			pt->ev=TRUE;
			g_timer_start(ramble->timer);
			g_timer_stop(ramble->timer);
		}
	} else if (ramble->timer) {
		g_timer_destroy(ramble->timer);
		ramble->timer=NULL;
	}
	END_FUNC
}
Example #8
0
void
ev_profiler_stop (EvProfileSection section,
		  const gchar     *format, ...)
{
	if (G_UNLIKELY (ev_profile & section)) {
		GTimer *timer;
		gchar  *name;
		va_list args;
		gdouble seconds;

		if (!format)
			return;

		va_start (args, format);
		name = g_strdup_vprintf (format, args);
		va_end (args);
		
		timer = g_hash_table_lookup (timers, name);
		if (!timer)
			return;
		
		g_timer_stop (timer);
		seconds = g_timer_elapsed (timer, NULL);
		g_print ("[ %s ] %f s elapsed\n", name, seconds);
		fflush (stdout);
	}
}
static void
handle_current_sync (GstDiscoverer * dc)
{
  GTimer *timer;
  gdouble deadline = ((gdouble) dc->priv->timeout) / GST_SECOND;
  GstMessage *msg;
  gboolean done = FALSE;

  timer = g_timer_new ();
  g_timer_start (timer);

  do {
    /* poll bus with timeout */
    /* FIXME : make the timeout more fine-tuned */
    if ((msg = gst_bus_timed_pop (dc->priv->bus, GST_SECOND / 2))) {
      done = handle_message (dc, msg);
      gst_message_unref (msg);
    }

  } while (!done && (g_timer_elapsed (timer, NULL) < deadline));

  /* return result */
  if (!done) {
    GST_DEBUG ("we timed out! Setting result to TIMEOUT");
    dc->priv->current_info->result = GST_DISCOVERER_TIMEOUT;
  }

  GST_DEBUG ("Done");

  g_timer_stop (timer);
  g_timer_destroy (timer);
}
Example #10
0
/**
 * ppg_session_channel_muted:
 * @connection: (in): A #PkConnection.
 * @result: (in): A #GAsyncResult.
 * @user_data: (closure): User data for callback.
 *
 * Callback upon the channel muting.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
ppg_session_channel_muted (GObject *object,
                           GAsyncResult *result,
                           gpointer user_data)
{
	PpgSession *session = user_data;
	PpgSessionPrivate *priv;
	GError *error = NULL;

	g_return_if_fail(PPG_IS_SESSION(session));

	priv = session->priv;

	if (!pk_connection_channel_mute_finish(priv->conn, result, &error)) {
		ppg_session_report_error(session, G_STRFUNC, error);
		g_error_free(error);
		return;
	}

	/*
	 * XXX: How do we deal with timer skew?
	 */
	priv->state = PPG_SESSION_PAUSED;
	g_timer_stop(priv->timer);

	ppg_session_stop_position_notifier(session);

	g_signal_emit(session, signals[PAUSED], 0);
}
Example #11
0
static void
song_paused(void)
{
	if (!was_paused)
		g_timer_stop(timer);
	was_paused = true;
}
Example #12
0
/**
 * ppg_session_connection_connected:
 * @connection: (in): A #PkConnection.
 * @result: (in): A #GAsyncResult.
 * @user_data: (closure): User data for callback.
 *
 * Callback upon the connection connecting to the agent.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
ppg_session_channel_stopped (GObject *object,
                             GAsyncResult *result,
                             gpointer user_data)
{
	PpgSession *session = user_data;
	PpgSessionPrivate *priv;
	GError *error = NULL;

	g_return_if_fail(PPG_IS_SESSION(session));

	priv = session->priv;

	if (!pk_connection_channel_stop_finish(priv->conn, result, &error)) {
		ppg_session_report_error(session, G_STRFUNC, error);
		g_error_free(error);
		return;

		/*
		 * FIXME: We need to make sure we handle this gracefully and stop
		 *        updating the UI. This goes for the rest of the states.
		 */
	}

	priv->state = PPG_SESSION_STOPPED;
	g_timer_stop(priv->timer);

	ppg_session_stop_position_notifier(session);

	g_signal_emit(session, signals[STOPPED], 0);
}
Example #13
0
/**
 * crank_bench_run_run:
 * @run: A Benchmark run.
 *
 * Performs single run of benchmark.
 */
void
crank_bench_run_run (CrankBenchRun *run)
{
  // Check run state.
  switch (run->state)
    {
    case CRANK_BENCH_RUN_RUNNING:
      g_warning ("Try running already running run.");
      return;

    case CRANK_BENCH_RUN_FINISHED:
      g_warning ("Try running finished run.");
      return;

    case CRANK_BENCH_RUN_PROCESSED:
      g_warning ("Try running processed run.");
      return;

    case CRANK_BENCH_RUN_NOT_RUN:
      break;
      // default.
    }

  // Run case.
  run->state = CRANK_BENCH_RUN_RUNNING;

  g_timer_start (run->timer_run);
  crank_bench_case_invoke (run->bcase, run);
  g_timer_stop (run->timer_run);

  run->state = CRANK_BENCH_RUN_FINISHED;
}
Example #14
0
int	main(int argc, char *argv[])
{
	GRand *rand;
	GTimer *timer;
	
	gint n;
	gint i, j;
	gint x = 0;
	rand = g_rand_new();	//创建随机数对象
	for(n=0; n<20; n++)
	{	//产生随机数并显示出来
		g_print("%d\t",g_rand_int_range(rand,1,100));
	}
	g_print("\n");
	g_rand_free(rand);	//释放随机数对象
	//创建计时器
	timer = g_timer_new();
	g_timer_start(timer);//开始计时
	for(i=0; i<10000; i++)
		for(j=0; j<3000; j++)
			x++;//累计
	g_timer_stop(timer);//计时结束
	//输出计时结果
	g_print("%ld\tall:%.2f seconds was used!\n",x,g_timer_elapsed(timer,NULL));
}
Example #15
0
complex double * gamma_spline_V(GammaSpline *gs, GList * const sd, double kc, int component)
{
    if (!gstimer) {
        gstimer = g_timer_new();
        g_timer_start(gstimer);
    }
    else g_timer_continue(gstimer);
    
    int NB = model->total_bands;
    
    complex double * V = complex_double_array_calloc (NB*NB);
    
    size_t m, n;

    for (m=0;m<NB;m++) {
        for (n=0;n<NB;n++) {
            gamma_spline_reset(gs,sd,m,n,FALSE);
            if (component==0) {
                V[m+n*NB]=gsl_interp_eval(gs->wx_spline_re,gs->k,gs->Wxr,kc,gs->w_accel)+I*gsl_interp_eval(gs->wx_spline_im,gs->k,gs->Wxi,kc,gs->w_accel);
            }
            else if (component==1) {
                V[m+n*NB]=gsl_interp_eval(gs->wy_spline_re,gs->k,gs->Wyr,kc,gs->w_accel)+I*gsl_interp_eval(gs->wy_spline_im,gs->k,gs->Wyi,kc,gs->w_accel);
            }
            else if (component==2) {
                V[m+n*NB]=gsl_interp_eval(gs->wz_spline_re,gs->k,gs->Wzr,kc,gs->w_accel)+I*gsl_interp_eval(gs->wz_spline_im,gs->k,gs->Wzi,kc,gs->w_accel);
            }
        }
    }
    g_timer_stop(gstimer);
    return V;
}
Example #16
0
Gamma * gamma_spline_calc_little_gamma (GammaSpline *gs, double * omega) { // without the one over omega
    if (!gstimer) {
        gstimer = g_timer_new();
        g_timer_start(gstimer);
    }
    else g_timer_continue(gstimer);

    int q=0;
	double kc;
    int Nkc = 16384;
    Gamma * g = gamma_new (Nkc);
    
    double dkc=2*KCMAX/Nkc;
    double denom=pow(KCMAX,4);
	for (kc=-KCMAX+dkc;kc<KCMAX;kc=kc+dkc) {
	    complex double a = gsl_interp_eval(gs->wx_spline_re,gs->k, gs->Wxr, kc,gs->w_accel)+I*gsl_interp_eval(gs->wx_spline_im,gs->k,gs->Wxi,kc,gs->w_accel);
	    double b = gsl_interp_eval_deriv(gs->phi_spline,gs->k, gs->phi, kc,gs->phi_accel);
	    omega[q]=b;
	    double damp = exp(-4*pow(fabs(kc),4)/denom);
	    
	    g->x[q]=a*damp;
	    
	    complex double c = gsl_interp_eval(gs->wy_spline_re,gs->k,gs->Wyr,kc,gs->w_accel)+I*gsl_interp_eval(gs->wy_spline_im,gs->k,gs->Wyi,kc,gs->w_accel);
	    g->y[q]=c*damp;
	    
	    complex double d = gsl_interp_eval(gs->wz_spline_re,gs->k,gs->Wzr,kc,gs->w_accel)+I*gsl_interp_eval(gs->wz_spline_im,gs->k,gs->Wzi,kc,gs->w_accel);
	    g->z[q]=d*damp;
	    
	    q++;
	}
    g_timer_stop(gstimer);
    
	return g;
}
Example #17
0
static guint
grab_frames_readout (UcaCamera *camera, gpointer buffer, guint n_frames, UcaCameraTriggerSource trigger_source, GTimer *timer)
{
    GError *error = NULL;
    guint recorded_frames = 0;

    g_object_set(camera, "trigger-source", trigger_source, NULL);
    uca_camera_start_recording(camera, &error);

    do {
        g_object_get (camera, "recorded-frames", &recorded_frames, NULL);
    }while(recorded_frames < n_frames);

    uca_camera_stop_recording(camera, &error);

    // This sets is-readout in camera object. So the grab is sequential from image 1
    uca_camera_start_readout(camera, &error);

    g_timer_start (timer);
    
    /*This is required because its possible that the camera has recorded frames more
    than what is required. Index starts at 1 for consistency (camRAM index start from 1)*/
    for(int i = 1; i <= n_frames; i++) {
        uca_camera_grab (camera, buffer, &error);
        if(error != NULL){
            g_warning("There was an error grabbing frame %d during readout from camRAM",i+1);
            error = NULL;
        }
    }

    g_timer_stop (timer);
    uca_camera_stop_readout(camera, &error);

    return n_frames;
}
Example #18
0
static guint
grab_frames_sync (UcaCamera *camera, gpointer buffer, guint n_frames, UcaCameraTriggerSource trigger_source, GTimer *timer)
{
    GError *error = NULL;
    guint total;

    g_object_set (camera, "trigger-source", trigger_source, NULL);
    uca_camera_start_recording (camera, &error);
    total = 0;

    g_timer_start (timer);
    for (guint i = 0; i < n_frames; i++) {
        if (trigger_source == UCA_CAMERA_TRIGGER_SOURCE_SOFTWARE)
            uca_camera_trigger (camera, &error);

        if (!uca_camera_grab (camera, buffer, &error))
            g_warning ("Data stream ended");

        if (error != NULL) {
            g_warning ("Error grabbing frame %02i/%i: `%s'", i, n_frames, error->message);
            g_error_free (error);
            error = NULL;
        }
        else {
            total++;
        }
    }
    g_timer_stop (timer);

    uca_camera_stop_recording (camera, &error);
    return total;
}
Example #19
0
static void menu_switch_to_fisheye(glCompObj *obj, GLfloat x, GLfloat y,
				   glMouseButtonType t)
{
    if (!view->Topview->fisheyeParams.active)
	{
	    if (!view->Topview->fisheyeParams.h) {
		prepare_topological_fisheye(view->g[view->activeGraph],view->Topview);
	    g_timer_start(view->timer);
	}
	view->Topview->fisheyeParams.active = 1;
	glCompButtonShow(toNormal);
	glCompButtonHide(toFisheye);
	imgFisheye->common.visible = 1;


    } else {
	view->Topview->fisheyeParams.active = 0;
	g_timer_stop(view->timer);
	glCompButtonHide(toNormal);
	glCompButtonShow(toFisheye);
	imgFisheye->common.visible = 0;


    }
}
Example #20
0
/* Starts, pauses  and continues the timer */
static void toggleTimer()
{
	if (prefs.timer_is_clock)
		return;

	switch (timerMode)
	{
		case 0:
			timer = g_timer_new();
			timerMode = 1;
			gtk_widget_set_sensitive(GTK_WIDGET(resetButton), FALSE);
			gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(startButton),
					GTK_STOCK_MEDIA_PAUSE);
			break;
		case 1:
			g_timer_stop(timer);
			timerMode = 2;
			gtk_widget_set_sensitive(GTK_WIDGET(resetButton), TRUE);
			gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(startButton),
					GTK_STOCK_MEDIA_PLAY);
			break;
		case 2:
			g_timer_continue(timer);
			timerMode = 1;
			gtk_widget_set_sensitive(GTK_WIDGET(resetButton), FALSE);
			gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(startButton),
					GTK_STOCK_MEDIA_PAUSE);
			break;
	}
}
bool probwin(probwin_context *c)
{
    /* Start counting time */
    GTimer* timer = g_timer_new();

    /* Run the probabilities to win algorithm */
    matrix* w = c->table_w;
    int games = c->games;
    float p;

    for(int i = 1; i < w->rows; i++) {
        for(int j = 1; j < w->columns; j++) {

            /* Decide which probability to use */
            int current_game = games + 1 - i - j;
            p = c->pr;
            if(c->game_format[current_game]) {
                p = c->ph;
            }

            w->data[i][j] = p * w->data[i - 1][j] +
                            (1.0 - p) * w->data[i][j - 1];
        }
    }

    /* Stop counting time */
    g_timer_stop(timer);
    c->execution_time = g_timer_elapsed(timer, NULL);
    g_timer_destroy(timer);
    return true;
}
Example #22
0
int main()
{
	GTimer *timer = g_timer_new();
	g_timer_start(timer);
	GQueue *queue = g_queue_new();
	g_queue_init(queue);
	int i;
	char *element;
	for(i=0;i<100;i++)
	{
		element = (char*)g_malloc(128);
		sprintf(element,"element_%d",i);
		g_queue_push_tail(queue,element);
	}	
	printf("%s\n",(char*)g_queue_pop_head(queue));	
	printf("%s\n",(char*)g_queue_pop_head(queue));	
	printf("%s\n",(char*)g_queue_pop_head(queue));	
	printf("%s\n",(char*)g_queue_pop_head(queue));
	g_queue_free(queue);
	g_timer_stop(timer);

	gulong *mincro;
	printf("%f\n",g_timer_elapsed(timer,mincro));
		
}
Example #23
0
static void next_test_case(void)
{
	struct test_case *test;

	if (test_current)
		test_current = g_list_next(test_current);
	else
		test_current = test_list;

	if (!test_current) {
		g_timer_stop(test_timer);

		g_main_loop_quit(main_loop);
		return;
	}

	test = test_current->data;

	printf("\n");
	print_progress(test->name, COLOR_BLACK, "init");

	test->start_time = g_timer_elapsed(test_timer, NULL);

	if (test->timeout > 0)
		test->timeout_id = g_timeout_add_seconds(test->timeout,
							test_timeout, test);

	test->stage = TEST_STAGE_PRE_SETUP;

	test->pre_setup_func(test->test_data);
}
Example #24
0
void start_timer()
    {
    GTimer *timer;
    timer = g_timer_new ();
    g_timer_start(timer);
    g_timer_stop(timer);
    }
Example #25
0
static int
process_message(SoupMessage *msg)
{
    struct request *req;
    char *data;
    GTimer *timer;
    gulong microsecs;

    timer = g_timer_new();
    g_timer_start(timer);

    req = request_new(msg->request_body->data);
    if (!req)
        return 1;

    data = request_response(req);
    if (!data)
        return 1;

    request_destroy(req);

    soup_message_set_response(msg, "application/json",
                              SOUP_MEMORY_TAKE, data, strlen(data));
    soup_message_set_status(msg, SOUP_STATUS_OK);

    g_timer_stop(timer);
    g_print("Time elapsed: %f\n", g_timer_elapsed(timer, &microsecs));
    g_timer_destroy(timer);
    return 0;
}
Example #26
0
static gboolean
mex_proxy_stop_timer_cb (MexProxy *proxy)
{
  MexProxyPrivate *priv = proxy->priv;

  g_timer_start (priv->timer);

  while (g_timer_elapsed (priv->timer, NULL) * 1000 < 5 &&
         !g_queue_is_empty (priv->to_add))
    {
      MexContent *content = g_queue_pop_head (priv->to_add);
      g_hash_table_remove (priv->to_add_hash, content);

      mex_proxy_add_content_no_defer (proxy, content);
      g_object_unref (content);
    }

  g_timer_stop (priv->timer);

  if (g_queue_is_empty (priv->to_add))
    {
      priv->timer_timeout = 0;
      return FALSE;
    }
  else
    return TRUE;
}
Example #27
0
static void timer_pause(struct application_info *app)
{
	if (app->timer.state == TIMER_RUNNING)
	{
		g_timer_stop(app->timer.gtimer);
		app->timer.state = TIMER_PAUSED;
	}
}
Example #28
0
void timeend()
{
    if (NULL == timeStamp) return;
    g_timer_stop(timeStamp);
    gulong microSecs = 0;
    gdouble secs = g_timer_elapsed(timeStamp, &microSecs);
    TRACE("time %f", secs);
}
Example #29
0
static void
test_xserver_sync (void)
{
  GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_xserver_sync");
  GtkWidget *darea = gtk_drawing_area_new ();
  GTimer *gtimer = g_timer_new();
  gint sync_is_slower = 0, repeat = 5;
  gtk_widget_set_size_request (darea, 320, 200);
  gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), darea);
  gtk_widget_show (darea);
  gtk_widget_show_now (window);
  while (repeat--)
    {
      gint i, many = 200;
      double nosync_time, sync_time;
      cairo_t *cr;

      while (gtk_events_pending ())
        gtk_main_iteration ();
      cr = gdk_cairo_create (darea->window);
      cairo_set_source_rgba (cr, 0, 1, 0, 0.1);
      /* run a number of consecutive drawing requests, just using drawing queue */
      g_timer_start (gtimer);
      for (i = 0; i < many; i++)
        {
          cairo_paint (cr);
        }
      g_timer_stop (gtimer);
      nosync_time = g_timer_elapsed (gtimer, NULL);
      gdk_flush();
      while (gtk_events_pending ())
        gtk_main_iteration ();
      g_timer_start (gtimer);
      /* run a number of consecutive drawing requests with intermediate drawing syncs */
      for (i = 0; i < many; i++)
        {
          cairo_paint (cr);
          gdk_test_render_sync (darea->window);
        }
      g_timer_stop (gtimer);
      sync_time = g_timer_elapsed (gtimer, NULL);
      sync_is_slower += sync_time > nosync_time * 1.5;
    }
  g_timer_destroy (gtimer);
  g_assert (sync_is_slower > 0);
}
static HostStealThreadData* _hoststealthreaddata_new() {
    HostStealThreadData* tdata = g_new0(HostStealThreadData, 1);

    tdata->unprocessedHosts = g_queue_new();
    tdata->processedHosts = g_queue_new();

    /* Create new timers to track thread idle times. The timers start in a 'started' state,
     * so we want to stop them immediately so we can continue/stop later around blocking code
     * to collect total elapsed idle time in the scheduling process throughout the entire
     * runtime of the program. */
    tdata->pushIdleTime = g_timer_new();
    g_timer_stop(tdata->pushIdleTime);
    tdata->popIdleTime = g_timer_new();
    g_timer_stop(tdata->popIdleTime);
    g_mutex_init(&(tdata->lock));
    tdata->runningHost = NULL;
    return tdata;
}