gtk application startup time



Hi all,
   I was tring to find the start up time of my gtk application ....
i am getting negative time. i am putting the code here. please comment on it...

windowA.c

#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <sys/time.h>
void callback_winb(GtkWidget *,gpointer);
extern GtkWidget *windowb;
GtkWidget *windowa;

//struct timeval timer(struct timeval);

/* This is a simple call back fuction for closing the window */

void 
callback1(GtkWidget *widget,
	 gpointer data)
{
	g_print("Pressed key is: %s\n",(gchar *)data);
	gtk_main_quit();
}
int
callback_wina(GtkWidget *widget,
   		gpointer data)
{
//	gtk_widget_hide(windowb);
	GtkWidget *boxa;
	GtkWidget *buttona;
	windowa=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(windowa),"Window A");
	g_signal_connect(G_OBJECT(windowa),"destroy",
			 G_CALLBACK(callback1),(gpointer)"Close");
	g_print("toggling to window b\n");
	gtk_container_set_border_width(GTK_CONTAINER(windowa),20);
	buttona=gtk_button_new_with_label("Toggle_A");
	g_signal_connect(G_OBJECT(buttona),"clicked",
			 G_CALLBACK(callback_winb),NULL);
	gtk_container_add(GTK_CONTAINER(windowa),buttona);
	gtk_widget_show_all(windowa);
}
int
main(int argc,
	char *argv[])
{
	struct timeval tp,tn;
	long times;
	gettimeofday(&tp,NULL);

	printf("tp.sec: %ld\n",tp.tv_sec);
	printf("tp.usec: %ld\n",tp.tv_usec);

	gtk_init(&argc,&argv);
	callback_wina(NULL,(gpointer)20);
	gtk_main();
	gettimeofday(&tn,NULL);

	printf("tn.sec: %ld\n",tn.tv_sec);
	printf("tn.usec: %ld\n",tn.tv_usec);

	times=((tn.tv_sec - tp.tv_sec)/1000000)+ 
		(tn.tv_usec - tp.tv_usec);
	printf("startup time : %ld\n ",times);
	return 0;
}	

windowB.c

#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
/* This is a simple call back fuction for closing the window */
void callback1(GtkWidget *,gpointer);
void callback_wina(GtkWidget *,gpointer);
extern GtkWidget *windowa;
GtkWidget *windowb;
void
callback_winb(GtkWidget *widget,
     		gpointer data)
{
	gtk_widget_hide(windowa);
	GtkWidget *boxb;
	GtkWidget *buttonb;
	windowb=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(windowb),"Window B");
	g_signal_connect(G_OBJECT(windowb),"destroy",
			 G_CALLBACK(callback1),(gpointer)"Close");
	g_print("toggling to window a\n");
	gtk_container_set_border_width(GTK_CONTAINER(windowb),20);
	buttonb=gtk_button_new_with_label("Toggle_B");
	g_signal_connect(G_OBJECT(buttonb),"clicked",
			 G_CALLBACK(callback_wina),NULL);
	gtk_container_add(GTK_CONTAINER(windowb),buttonb);
	gtk_widget_show_all(windowb);
}

makefile
	
#make file for toggle windows
togg: windowA.c windowB.c 
	gcc -g windowA.c windowB.c  -o togg `pkg-config --cflags --libs gtk+-2.0`
clean:
	rm -f togg


With regds,

 

Shyjumon N
Mobile: +91-9945006965



<<winmail.dat>>

The information contained in this e-mail message and in any annexure is confidential to the  recipient and may contain privileged information. If you are not the intended recipient, please notify the sender and delete the message along with any annexure. You should not disclose, copy or otherwise use the information contained
in the message or any annexure. Any views expressed in this e-mail are those of the individual sender except where the sender specifically states them to be the views of SoCrates Software India Pvt Ltd., Bangalore.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]