Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

measure boot time

2 views
Skip to first unread message

Keppler Alecrim

unread,
Nov 22, 2006, 3:17:40 PM11/22/06
to
Hi all ,
   I created a simple module to measure boot time,that is loaded on last run level of my machine. Any comment about the code or a better way?
thanks  ;)

code :

//-------------------------------------------------------------------
//      boottime.c
//
//      Created by : Francisco Alecrim (francisc...@indt.org.br)
//      Wed Nov 22 15:28:30 AMT 2006
//-------------------------------------------------------------------

#include <linux/module.h>       // for init_module()
#include <linux/proc_fs.h>      // for create_proc_info_entry()
#include <linux/jiffies.h>

static char modname[] = "boottime";
unsigned long jiffiesend=0;

static int proc_read ( char *buf, char **start, off_t off, int count )
{
        int     len;
        unsigned long jiffiesinit,freq;
        len = 0;
        jiffiesinit=INITIAL_JIFFIES;
        freq=HZ;
        len += sprintf (buf+len, "timestamp-cpu freq (HZ) = %lu \n",freq);
        len += sprintf (buf+len, "timestamp-jiffies init= %lu \n",jiffiesinit);
        len += sprintf( buf+len, "timestamp-jiffies end = %lu \n", jiffiesend );
        len += sprintf( buf+len, "timestamp-jiffies diff= %lu \n", (jiffiesend-jiffiesinit) );
        len += sprintf (buf+len, "timestamp-boot time in sec  = %lu \n",((jiffiesend-jiffiesinit)/freq) );

        return  len;
}


int init_module( void )
{
        printk( "<1>\nInstalling \'%s\' module\n", modname );
        jiffiesend=jiffies;
        create_proc_info_entry( modname, 0, NULL, proc_read );
        return  0;  //SUCCESS
}


void cleanup_module( void )
{
        remove_proc_entry( modname, NULL );
        printk( "<1>Removing \'%s\' module\n", modname );
}

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Francisco Alecrim(francisc...@indt.org.br)");
MODULE_VERSION("0.1");



--
--
Francisco Keppler Silva Alecrim
INdT - OSMRC
0 new messages