measure boot time

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

 



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 (francisco.alecrim@xxxxxxxxxxx)
//      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(francisco.alecrim@xxxxxxxxxxx)");
MODULE_VERSION("0.1");



--
--
Francisco Keppler Silva Alecrim
INdT - OSMRC

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux