Showing posts with label cpu. Show all posts
Showing posts with label cpu. Show all posts

Sunday, August 28, 2011

Profiling Perl Code

I've started using NYTProf to profile and optimise my perl code. It produces a very useful report showing how much time is spent in each subroutine and statement.

Usage:

perl -d:NYTProf script.pl
or
perl -d:NYTProf -I/path/to/Devel-NYTProf/4.06/lib/perl5 script.pl
The output of the profiler is written to ./nytprof.out.

Use the following command to create HTML reports from the profiler's results:

/path/Devel-NYTProf/4.06/bin/nytprofhtml --file nytprof.out -out ./htmlReports --delete

Friday, May 08, 2009

Solaris - CPU, Memory and Version

CPU Info:
In order to find information about processors on Solaris, use the psrinfo command:
sharfah@starship:~> psrinfo -v
Status of virtual processor 0 as of: 05/08/2009 09:53:17
  on-line since 05/03/2009 00:05:06.
  The i386 processor operates at 2612 MHz,
        and has an i387 compatible floating point processor.
Status of virtual processor 1 as of: 05/08/2009 09:53:17
  on-line since 05/03/2009 00:05:12.
  The i386 processor operates at 2612 MHz,
        and has an i387 compatible floating point processor.
Status of virtual processor 2 as of: 05/08/2009 09:53:17
  on-line since 05/03/2009 00:05:14.
  The i386 processor operates at 2612 MHz,
        and has an i387 compatible floating point processor.
Status of virtual processor 3 as of: 05/08/2009 09:53:17
  on-line since 05/03/2009 00:05:16.
  The i386 processor operates at 2612 MHz,
        and has an i387 compatible floating point processor.
Status of virtual processor 4 as of: 05/08/2009 09:53:17
  on-line since 05/03/2009 00:05:18.
  The i386 processor operates at 2612 MHz,
        and has an i387 compatible floating point processor.
Status of virtual processor 5 as of: 05/08/2009 09:53:17
  on-line since 05/03/2009 00:05:20.
  The i386 processor operates at 2612 MHz,
        and has an i387 compatible floating point processor.
Status of virtual processor 6 as of: 05/08/2009 09:53:17
  on-line since 05/03/2009 00:05:22.
  The i386 processor operates at 2612 MHz,
        and has an i387 compatible floating point processor.
Status of virtual processor 7 as of: 05/08/2009 09:53:17
  on-line since 05/03/2009 00:05:24.
  The i386 processor operates at 2612 MHz,
        and has an i387 compatible floating point processor.
Memory Info:
In order to find out how much physical memory is installed, use prtconf:
sharfah@starship:~> prtconf | grep Memory
Memory size: 65536 Megabytes
Version Info:
To show machine, software revision and patch revision information use the showrev command:
sharfah@starship:~> showrev
Hostname: starship
Hostid: 80f32709
Release: 5.10
Kernel architecture: i86pc
Application architecture: i386
Hardware provider:
Kernel version: SunOS 5.10 Generic_137112-06
sharfah@starship:~> uname -a
SunOS starship 5.10 Generic_137112-06 i86pc i386 i86pc
Processes:
In order to list the processes running, use prstat (equivalent to top).
sharfah@starship:~> prstat
  PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
 4049 sharfah   1008K  840K sleep    0    0   0:03.17 0.3% find/1
14632 sharfah      114M   68M sleep   29   10   1:19.18 0.1% java/30
Related posts:
Linux - CPU, Memory and Version

Friday, October 03, 2008

Checking CPU Utilisation on Linux

Here are a few commands which can be used to investigate CPU utilisation on Linux:

top
The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel. The CPU usage shows the task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.

top - 18:12:28 up 40 days, 18:35,  1 user,  load average: 0.13, 0.03, 0.01
Tasks:  98 total,   1 running,  96 sleeping,   0 stopped,   1 zombie
Cpu(s):  0.2% us,  0.0% sy,  0.0% ni, 99.4% id,  0.4% wa,  0.0% hi,  0.0% si
Mem:   8002512k total,  3845332k used,  4157180k free,    64624k buffers
Swap:  9437144k total,   771048k used,  8666096k free,  1831288k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      16   0   640   80   48 S  0.0  0.0  43:04.18 init
    2 root      RT   0     0    0    0 S  0.0  0.0   0:00.70 migration/0
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.02 ksoftirqd/0
    4 root      RT   0     0    0    0 S  0.0  0.0   0:00.58 migration/1
    5 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/1
    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.40 migration/2
    7 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/2
    8 root      RT   0     0    0    0 S  0.0  0.0   0:00.46 migration/3

sar
The sar command can be used to display a history of CPU usage:
10:00:01   CPU     %user     %nice   %system   %iowait   %idle
10:10:01   all     34.45      2.04     30.03      0.05   33.43
10:20:01   all     34.13      1.77     29.85      0.08   34.17

mpstat
The mpstat command can be used to show the percentage of CPU usage for each processor:
> mpstat -P ALL

18:02:42     CPU   %user   %nice %system %iowait    %irq
18:02:42     all   24.77   17.51   21.56    1.19    0.01
18:02:42       0   25.00   17.92   20.27    0.94    0.00
18:02:42       1   23.81   17.03   20.87    0.88    0.00
18:02:42       2   26.28   16.44   22.23    1.54    0.01
18:02:42       3   24.00   18.65   22.86    1.39    0.01
Order ps output
The following command displays the top 10 CPU users on your system. It involves listing the processes using ps and then sorting them by CPU usage:
> ps -eo pcpu,pid,user,cmd | sort -k 1 -r | head -10

%CPU   PID USER     CMD
 0.1    13 root     [events/3]
 0.1   103 root     [kswapd0]
 0.1   102 root     [kswapd1]
 0.0     9 root     [ksoftirqd/3]
 0.0     8 root     [migration/3]
 0.0  8982 root     [lockd]
 0.0  8981 root     [rpciod]
 0.0     7 root     [ksoftirqd/2]
 0.0    75 root     [kblockd/3]