Ejemplo n.º 1
0
static void
song_changed(const struct mpd_song *song)
{
	g_assert(song != NULL);

	if (mpd_song_get_tag(song, MPD_TAG_ARTIST, 0) == NULL ||
			mpd_song_get_tag(song, MPD_TAG_TITLE, 0) == NULL) {
		g_message("New song detected with tags missing (%s)",
				mpd_song_get_uri(song));
		g_timer_start(timer);
		return;
	}
	g_timer_start(timer);

	g_debug("New song detected (%s - %s), id: %u, pos: %u",
			mpd_song_get_tag(song, MPD_TAG_ARTIST, 0),
			mpd_song_get_tag(song, MPD_TAG_TITLE, 0),
			mpd_song_get_id(song), mpd_song_get_pos(song));

	as_now_playing(mpd_song_get_tag(song, MPD_TAG_ARTIST, 0),
			mpd_song_get_tag(song, MPD_TAG_TITLE, 0),
			mpd_song_get_tag(song, MPD_TAG_ALBUM, 0),
			mpd_song_get_tag(song, MPD_TAG_MUSICBRAINZ_TRACKID, 0),
			mpd_song_get_duration(song));
}
Ejemplo n.º 2
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
}
Ejemplo n.º 3
0
int main(void) {
    RmTrie trie;
    rm_trie_init(&trie);
    GTimer *timer = g_timer_new();

    g_timer_start(timer);
    char buf[1024];
    int i = 0;

    while(fgets(buf, sizeof(buf), stdin)) {
        buf[strlen(buf) - 1] = 0;
        rm_trie_insert(&trie, buf, GUINT_TO_POINTER(++i));
        memset(buf, 0, sizeof(buf));
    }

    g_printerr("Took %2.5f to insert %d items\n", g_timer_elapsed(timer, NULL), i);
    rm_trie_print(&trie);
    memset(buf, 0, sizeof(buf));
    rm_trie_build_path(&trie, rm_trie_search_node(&trie, "/usr/bin/rmlint"), buf,
                       sizeof(buf));
    g_printerr("=> %s\n", buf);

    g_timer_start(timer);
    const int N = 10000000;
    for(int x = 0; x < N; x++) {
        rm_trie_search(&trie, "/usr/bin/rmlint");
    }
    g_printerr("Took %2.5f to search\n", g_timer_elapsed(timer, NULL));

    g_printerr("%u\n", GPOINTER_TO_UINT(rm_trie_search(&trie, "/usr/bin/rmlint")));
    g_printerr("%u\n", GPOINTER_TO_UINT(rm_trie_search(&trie, "/a/b/c")));
    rm_trie_destroy(&trie);
    g_timer_destroy(timer);
    return 0;
}
Ejemplo n.º 4
0
static void
render_thread(void *ptr)
{
	GtkWidget * widget = (GtkWidget *) ptr;
	VGAText * vga;
	GTimer *timer;
	long elapsed_ms;

	g_return_if_fail(widget != NULL);
	g_return_if_fail(VGA_IS_TEXT(widget));
	vga = VGA_TEXT(widget);

	timer = g_timer_new();

	g_timer_start(timer);
	while (vga->pvt->render_enabled) {
		gdk_threads_enter();
		vga_render_buf((gpointer) widget);
		gdk_threads_leave();
		elapsed_ms = (long) g_timer_elapsed(timer, NULL) * 1000;
		if (elapsed_ms > RENDER_PERIOD_MS) {
			printf("Took longer than %d ms to render, or gtk main"
			    "blocked for a long time.\n", RENDER_PERIOD_MS);
		}  else {
			g_usleep((RENDER_PERIOD_MS*1000) -
				 (elapsed_ms*1000));
		}
		g_timer_start(timer);
	}
}
Ejemplo n.º 5
0
/**
 * Aquire the IO lock
 */
void
rs_io_lock_real(const gchar *source_file, gint line, const gchar *caller)
{
	RS_DEBUG(LOCKING, "[%s:%d %s()] \033[33mrequesting\033[0m IO lock (thread %p)",
		source_file, line, caller,
		(g_timer_start(io_lock_timer), g_thread_self()));

	/* Each loop tries approx every millisecond, so we wait 10 secs */
	int tries_left = 10*1000;

	while (FALSE == g_static_rec_mutex_trylock(&io_lock));
	{
		g_usleep(1000);
		if (--tries_left <= 0)
		{
			RS_DEBUG(LOCKING, "[%s:%d %s()] \033[31mIO Lock was not released after \033[36m%.2f\033[0mms\033[0m, ignoring IO lock (thread %p)",
				source_file, line, caller,
				g_timer_elapsed(io_lock_timer, NULL)*1000.0,
				(g_timer_start(io_lock_timer), g_thread_self()));
			return;
		}
	}

	RS_DEBUG(LOCKING, "[%s:%d %s()] \033[32mgot\033[0m IO lock after \033[36m%.2f\033[0mms (thread %p)",
		source_file, line, caller,
		g_timer_elapsed(io_lock_timer, NULL)*1000.0,
		(g_timer_start(io_lock_timer), g_thread_self()));
}
Ejemplo n.º 6
0
void           remote_client_connect          (RemoteClient*         self)
{
    /* Clean up after the previous connection, if we need to */
    if (self->gconn) {
	gnet_conn_delete(self->gconn);
	self->gconn = NULL;
    }
    remote_client_empty_queue(self);

    /* Reset our speed counters and rate limiting timers */
    self->iter_accumulator = 0;
    self->byte_accumulator = 0;
    self->iters_per_sec = 0;
    self->bytes_per_sec = 0;
    g_timer_start(self->stream_request_timer);
    g_timer_start(self->status_speed_timer);
    g_timer_start(self->stream_speed_timer);

    /* Create the new connection object */
    self->gconn = gnet_conn_new(self->host, self->port, remote_client_callback, self);
    gnet_conn_set_watch_error(self->gconn, TRUE);
    gnet_conn_connect(self->gconn);
    gnet_conn_readline(self->gconn);

    remote_client_update_status(self, "Connecting...");
}
static void
test_coglbox_paint(ClutterActor *self)
{
  TestCoglboxPrivate *priv;
  
  ClutterColor cfill;
  ClutterColor cstroke;
  
  static GTimer *timer = NULL;
  static gint paint_index = 0;
  
  gint NUM_PAINT_FUNCS;
 
  NUM_PAINT_FUNCS = G_N_ELEMENTS (paint_func);
  
  priv = TEST_COGLBOX_GET_PRIVATE (self);
  
  
  if (!timer)
    {
      timer = g_timer_new ();
      g_timer_start (timer);
    }
  
  if (g_timer_elapsed (timer, NULL) >= 1)
    {
      paint_index += 1;
      paint_index = paint_index % NUM_PAINT_FUNCS;
      g_timer_start (timer);
    }
  
  cfill.red    = 0;
  cfill.green  = 160;
  cfill.blue   = 0;
  cfill.alpha  = 255;
  
  cstroke.red    = 200;
  cstroke.green  = 0;
  cstroke.blue   = 0;
  cstroke.alpha  = 255;
  
  cogl_push_matrix ();
  
  paint_func[paint_index] ();
  
  cogl_translate (100,100,0);
  cogl_color (&cstroke);
  cogl_path_stroke ();
  
  cogl_translate (150,0,0);
  cogl_color (&cfill);
  cogl_path_fill ();
  
  cogl_pop_matrix();

}
Ejemplo n.º 8
0
static gboolean stop_number_verbose (gdouble cost, guint number, guint * min)
{
  static guint nmax = 0, nold = 0;
  static GTimer * timer = NULL, * total_timer = NULL;

  g_return_val_if_fail (min != NULL, TRUE);

  if (timer == NULL) {
    nmax = nold = number;
    timer = g_timer_new ();
    total_timer = g_timer_new ();
    g_timer_start (total_timer);
  }

  if (number != nold && number % 121 == 0 &&
      number < nmax && nmax > *min) {
    gdouble total_elapsed = g_timer_elapsed (total_timer, NULL);
    gdouble remaining;
    gdouble hours, mins, secs;
    gdouble hours1, mins1, secs1;

    g_timer_stop (timer);

    hours = floor (total_elapsed/3600.);
    mins = floor ((total_elapsed - 3600.*hours)/60.);
    secs = floor (total_elapsed - 3600.*hours - 60.*mins);

    remaining = total_elapsed*((nmax - *min)/(gdouble) (nmax - number) - 1.);
    hours1 = floor (remaining/3600.);
    mins1 = floor ((remaining - 3600.*hours1)/60.);
    secs1 = floor (remaining - 3600.*hours1 - 60.*mins1);

    fprintf (stderr, 
	     "\rEdges: %10u %3.0f%% %6.0f edges/s "
	     "Elapsed: %02.0f:%02.0f:%02.0f "
	     "Remaining: %02.0f:%02.0f:%02.0f ",
	     number, 
	     100.*(nmax - number)/(nmax - *min),
	     (nold - number)/g_timer_elapsed (timer, NULL),
	     hours, mins, secs,
	     hours1, mins1, secs1);
    fflush (stderr);

    nold = number;
    g_timer_start (timer);
  }
  if (number < *min) {
    g_timer_destroy (timer);
    g_timer_destroy (total_timer);
    return TRUE;
  }
  return FALSE;
}
Ejemplo n.º 9
0
int sender( SAPO_BROKER_T *conn, int msg_type, char * topic, char * message){
	int i=0 , c=0;
	char str[1024*8];
	
        GTimer * gtime_iter;
        gtime_iter = g_timer_new();        
        
        g_timer_start(gtime_iter);
	while(i < 10){
                
		i++;
                c++;
		if (!conn->connected){
			if (sb_reconnect(conn) ){
				printf("Problems connecting: %s\n", strerror(conn->last_status));
				sleep(1);
				continue;
			}
		}
		
		//sprintf(str,ADW_QUEUE_STRING,i++, time(NULL));
		//printf ("word_id = %d\n", i);
		//sprintf(str,ADW_QUEUE_STRING, (unsigned int)time(NULL) );
		
                sprintf(str,"%d",i);
		//sprintf(str,"AAAAAAA generating %d AAAAAAA",i);		
		//if (i%100 ==0)
		//	printf("%d\n",i);
			//i++;

		if (sb_publish_time(conn, msg_type, topic, str,10)<0){
			printf("Connection was broken when sending. Reconnecting\n");
			sleep(1);
			sb_reconnect(conn);
			continue;
		}
                
                if (c%1000==0){
                        float a= g_timer_elapsed(gtime_iter,NULL);
                        printf("Sending %d msg in %.2f : %.2f messages per second\n", c, a, (float)c/a );
                        g_timer_start(gtime_iter);
                        c= 0;
                }
                
		//usleep(1);
	}
	printf("going away\n");
	return 0;
}
Ejemplo n.º 10
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;
}
Ejemplo n.º 11
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;


    }
}
Ejemplo n.º 12
0
static void steadyflow_file_list_controller_on_progress_notify (SteadyflowFileListController* self) {
	GtkTreeView* _tmp0_;
	GtkWidget* _tmp1_ = NULL;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GTimer* _tmp4_;
	gdouble _tmp5_ = 0.0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->tree;
	_tmp1_ = gtk_widget_get_toplevel ((GtkWidget*) _tmp0_);
	_tmp2_ = gtk_widget_get_visible (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		return;
	}
	_tmp4_ = self->priv->redraw_timer;
	_tmp5_ = g_timer_elapsed (_tmp4_, NULL);
	if (_tmp5_ >= STEADYFLOW_FILE_LIST_CONTROLLER_REDRAW_SEC) {
		GTimer* _tmp6_;
		GtkTreeView* _tmp7_;
		_tmp6_ = self->priv->redraw_timer;
		g_timer_start (_tmp6_);
		_tmp7_ = self->priv->tree;
		gtk_widget_queue_draw ((GtkWidget*) _tmp7_);
	}
}
Ejemplo n.º 13
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));
		
}
Ejemplo n.º 14
0
void
electron_manager_set_full_speed (ElectronManager *eman,
                                 gboolean full_speed)
{
  ElectronManagerPrivate *priv = eman->priv;

  if (priv->full_speed != full_speed)
  {
    priv->full_speed = full_speed;

    if (priv->timeout)
    {
      g_source_remove (priv->timeout);
      if (full_speed)
      {
        priv->timeout = g_idle_add ((GSourceFunc) electron_manager_timeout,
                                    eman);
        g_timer_start (priv->full_speed_timer);
      }
      else
        priv->timeout
          = frame_source_add (ELECTRON_TICKS_PER_FRAME,
                              (GSourceFunc) electron_manager_timeout,
                              eman, NULL);
    }
  }
}
Ejemplo n.º 15
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;
}
Ejemplo n.º 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;
}
Ejemplo n.º 17
0
static MidgardConnectionPrivate *
midgard_connection_private_new (void)
{
	MidgardConnectionPrivate *cnc_private = 
		g_new(MidgardConnectionPrivate, 1);

	cnc_private->pattern = NULL;	
	cnc_private->config = NULL;
	cnc_private->connected = FALSE;
	cnc_private->loghandler = 0;
	cnc_private->loglevel = 0;	
	cnc_private->user = NULL;
	cnc_private->inherited = FALSE;
	cnc_private->parser = NULL;
	cnc_private->connection = NULL;
	cnc_private->configname = NULL;
	cnc_private->cnc_str = NULL;

	cnc_private->error_clbk_connected = FALSE;
	cnc_private->authtypes = NULL;
	cnc_private->authstack = NULL;

	/* Initialize thread *if* you need correct connection uptime when you use only one procces.
	   It works fine in child proccesses */
	/* g_thread_init(NULL); */
	cnc_private->timer = g_timer_new();
	g_timer_start(cnc_private->timer);	

	cnc_private->enable_replication = FALSE;
	cnc_private->enable_quota = FALSE;
	cnc_private->enable_debug = FALSE;
	cnc_private->enable_dbus = FALSE;

	return cnc_private;
}
static void
activity_detected_cb (DrwMonitor *monitor,
		      DrWright   *dr)
{
	dr->is_active = TRUE;
	g_timer_start (dr->idle_timer);
}
Ejemplo n.º 19
0
static gboolean
client_out_event(G_GNUC_UNUSED GIOChannel *source, GIOCondition condition,
         gpointer data)
{
    struct client *client = data;

    assert(!client_is_expired(client));

    if (condition != G_IO_OUT) {
        client_set_expired(client);
        return false;
    }

    client_write_deferred(client);

    if (client_is_expired(client)) {
        client_close(client);
        return false;
    }

    g_timer_start(client->last_activity);

    if (g_queue_is_empty(client->deferred_send)) {
        /* done sending deferred buffers exist: schedule
           read */
        client->source_id = g_io_add_watch(client->channel,
                           G_IO_IN|G_IO_ERR|G_IO_HUP,
                           client_in_event, client);
        return false;
    }

    /* write more */
    return true;
}
Ejemplo n.º 20
0
static gboolean
gdm_display_real_manage (GdmDisplay *display)
{
    gboolean res;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    g_debug ("GdmDisplay: manage display");

    /* If not explicitly prepared, do it now */
    if (display->priv->status == GDM_DISPLAY_UNMANAGED) {
        res = gdm_display_prepare (display);
        if (! res) {
            return FALSE;
        }
    }

    g_assert (display->priv->slave_proxy != NULL);

    g_timer_start (display->priv->slave_timer);

    gdm_slave_proxy_start (display->priv->slave_proxy);

    return TRUE;
}
Ejemplo n.º 21
0
static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi)
{
	struct dev_context *devc;
	struct sr_serial_dev_inst *serial;

	if (sdi->status != SR_ST_ACTIVE)
		return SR_ERR_DEV_CLOSED;

	devc = sdi->priv;
	devc->settings_ok = FALSE;
	devc->buflen = 0;

	std_session_send_df_header(sdi, LOG_PREFIX);

	/* Start timer, if required. */
	if (devc->limit_msec)
		g_timer_start(devc->elapsed_msec);

	/* Poll every 40ms, or whenever some data comes in. */
	serial = sdi->conn;
	serial_source_add(sdi->session, serial, G_IO_IN, 40,
			gmc_mh_2x_receive_data, (void *)sdi);

	/* Send start message */
	return req_meas14(sdi);
}
Ejemplo n.º 22
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;
}
Ejemplo n.º 23
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;
}
Ejemplo n.º 24
0
static gboolean
electron_manager_timeout (ElectronManager *eman)
{
  ElectronManagerPrivate *priv = eman->priv;

  g_return_val_if_fail (IS_ELECTRON_MANAGER (eman), FALSE);
  g_return_val_if_fail (priv->timeout != 0, FALSE);

  if (electron_run_frame (eman->data))
    /* Breakpoint was hit, so stop the electron */
    electron_manager_stop (eman);
  /* Otherwise we've done a whole frame so emit the frame end
     signal. If we're running at full speed we'll only emit the frame
     end signal if enough time has elapsed (so not every frame will be
     drawn) */
  else if (priv->full_speed)
  {
    if (g_timer_elapsed (priv->full_speed_timer, NULL) * 1000.0
        > ELECTRON_TICKS_PER_FRAME)
    {
      g_timer_start (priv->full_speed_timer);
      g_signal_emit (G_OBJECT (eman),
                     electron_manager_signals[ELECTRON_MANAGER_FRAME_END_SIGNAL], 0);
    }
  }
  else
    g_signal_emit (G_OBJECT (eman),
                   electron_manager_signals[ELECTRON_MANAGER_FRAME_END_SIGNAL], 0);

  return TRUE;
}
Ejemplo n.º 25
0
void
ev_profiler_start (EvProfileSection section,
		   const gchar     *format, ...)
{
	if (G_UNLIKELY (ev_profile & section)) {
		GTimer *timer;
		gchar  *name;
		va_list args;

		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) {
			timer = g_timer_new ();
			g_hash_table_insert (timers, g_strdup (name), timer);
		} else {
			g_timer_start (timer);
		}
	}
}
Ejemplo n.º 26
0
static void
query_cb (GObject      *object,
          GAsyncResult *res,
          gpointer      user_data)
{
	TrackerSparqlCursor *cursor;
	GError *error = NULL;
	MyData *md = user_data;

	cursor = tracker_sparql_connection_query_finish (TRACKER_SPARQL_CONNECTION (object),
	                                                 res,
	                                                 &error);
	g_print ("Async query took: %.6f\n", g_timer_elapsed (md->timer, NULL));

	g_timer_start (md->timer);

	if (!error) {
		tracker_sparql_cursor_next_async (cursor,
		                                  md->cancellable,
		                                  cursor_cb,
		                                  md);
	} else {
		g_critical ("Could not run query: %s", error->message);

		if (cursor) {
			g_object_unref (cursor);
		}

		g_error_free (error);
		g_main_loop_quit (md->loop);
	}
}
Ejemplo n.º 27
0
static int gtkui_progress_wrap(char *title, int value, int max) {

   struct gtkui_progress_data *gpd;

   if (value <= 1) {
      g_timer_start(progress_timer);
      progress_canceled = FALSE;
   }

   if (progress_canceled == TRUE) {
      return UI_PROGRESS_INTERRUPTED;
   }

   if (!title) {
    return UI_PROGRESS_UPDATED;
   }

   gpd = malloc(sizeof *gpd);
   if (gpd) {
      gpd->title = strdup(title);
      gpd->value = value;
      gpd->max = max;
      g_idle_add(gtkui_progress_shim, gpd);
   } else {
      FATAL_ERROR("out of memory");
   }

   return value == max
      ? UI_PROGRESS_FINISHED
      : UI_PROGRESS_UPDATED;
}
Ejemplo n.º 28
0
static void    histogram_merge_callback       (RemoteClient*     self,
					       RemoteResponse*   response,
					       gpointer          user_data)
{
    HistogramImager *dest = HISTOGRAM_IMAGER(user_data);
    double elapsed;

    self->pending_stream_requests--;

    if (self->pending_param_changes) {
	/* This data is for an old parameter set, ignore it.
	 * FIXME: This doesn't distinguish between parameters that
	 *        actaully affect calculation and those that don't.
	 */
	return;
    }

    if (!response->data_length)
	return;

    histogram_imager_merge_stream(dest, response->data, response->data_length);

    /* Update our download speed */
    self->byte_accumulator += response->data_length;
    elapsed = g_timer_elapsed(self->stream_speed_timer, NULL);
    if (elapsed > MINIMUM_SPEED_WINDOW) {
	g_timer_start(self->stream_speed_timer);
	self->bytes_per_sec = self->byte_accumulator / elapsed;
	self->byte_accumulator = 0;
    }
}
Ejemplo n.º 29
0
static void new_frame_cb( unicap_event_t event, unicap_handle_t handle, unicap_data_buffer_t *buffer, GTimer *fps_timer )
{
	gdouble ival, fps;
	static int ctr = 0;
	gchar txt[32];
	ucil_color_t c, dc;

	static ucil_font_object_t *fobj = NULL;
	
	ival = g_timer_elapsed( fps_timer, NULL );
	if (ival == 0.0 )
		ival = 1.0;
	g_timer_start( fps_timer );

	fps = 1.0 / ival;
	
	c.rgb24.r = c.rgb24.g = c.rgb24.b = 255;
	c.colorspace = UCIL_COLORSPACE_RGB24;
	
	dc.colorspace = UCIL_COLORSPACE_YUV;
	ucil_convert_color (&dc, &c);

	if (!fobj)
		fobj = ucil_create_font_object (12, NULL);
	
	sprintf (txt, "% 2.1f FPS %d Frames", fps, ctr++);
	/* ucil_draw_text (buffer, &dc, fobj, txt, 10, 10); */

	
	if ((ctr % 10) == 0){
		gdk_threads_enter();
		gtk_window_set_title( GTK_WINDOW( display_window ), txt );
		gdk_threads_leave();
	}
}
Ejemplo n.º 30
0
void
electron_manager_start (ElectronManager *eman)
{
  ElectronManagerPrivate *priv = eman->priv;

  g_return_if_fail (IS_ELECTRON_MANAGER (eman));

  if (priv->timeout == 0)
  {
    if (priv->full_speed)
    {
      priv->timeout = g_idle_add ((GSourceFunc) electron_manager_timeout,
                                  eman);
      g_timer_start (priv->full_speed_timer);
    }
    else
      priv->timeout
        = frame_source_add (ELECTRON_TICKS_PER_FRAME,
                            (GSourceFunc) electron_manager_timeout,
                            eman, NULL);

    g_signal_emit (G_OBJECT (eman),
                   electron_manager_signals[ELECTRON_MANAGER_STARTED_SIGNAL], 0);
    /* If we're breaking at the current address then skip over one
       instruction. Otherwise when the breakpoint is hit continuing
       the emulation will cause it to break immediatly */
    if (eman->data->cpu.break_type == CPU_BREAK_ADDR
        && eman->data->cpu.break_address == eman->data->cpu.pc)
      electron_step (eman->data);
  }
}