PDA

View Full Version : Misurare la quantità di memoria utilizzata da un programma a run-time.


Vincenzo1968
29-01-2013, 14:38
Come si può fare? Che strumenti si possono utilizzare?

Ovviamente si dispone soltanto dell'eseguibile senza i sorgenti.

sottovento
29-01-2013, 14:42
Come si può fare? Che strumenti si possono utilizzare?

Ovviamente si dispone soltanto dell'eseguibile senza i sorgenti.

Qualcosa oltre i "soliti" strumenti, intendi? Per esempio, sotto Windows uso spesso Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) che ti da' un bel po di informazioni. C'e' qualcosa di simile, probabilmente anche piu' sofisticato sotto i sistemi *nix.

Stai cercando questo?

Vincenzo1968
29-01-2013, 14:47
Qualcosa oltre i "soliti" strumenti, intendi? Per esempio, sotto Windows uso spesso Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) che ti da' un bel po di informazioni. C'e' qualcosa di simile, probabilmente anche piu' sofisticato sotto i sistemi *nix.

Stai cercando questo?

Minchia! Mark Russinovich!
Grazie mille per il link! :D

Anche coi soliti strumenti(che non conosco :cry: ).

Mi servirebbe qualcosa anche per Linux.

The_ouroboros
29-01-2013, 14:53
ps -ax (o ancor meglio ps -ef )e top soco tuoi amici :D

Vincenzo1968
29-01-2013, 14:56
ps -ax (o ancor meglio ps -ef )e top soco tuoi amici :D

Thanks a lot!

Lo provo subito.

:D

Vincenzo1968
29-01-2013, 15:03
http://img17.imageshack.us/img17/630/memorymeasurement.jpg

Come lo uso? Se ho un eseguibile chiamato "myapp" come faccio a misurare la memoria utilizzata?

Vincenzo1968
29-01-2013, 15:11
.

Usage:
ps [options]

Basic options:
-A, -e all processes
-a all with tty, except session leaders
a all with tty, including other users
-d all except session leaders
-N, --deselect negate selection
r only running processes
T all processes on this terminal
x processes without controlling ttys

Selection by list:
-C <command> command name
-G, --Group <gid> real group id or name
-g, --group <group> session or effective group name
-p, --pid <pid> process id
--ppid <pid> select by parent process id
-s, --sid <session> session id
-t, t, --tty <tty> terminal
-u, U, --user <uid> effective user id or name
-U, --User <uid> real user id or name

selection <arguments> take either:
comma-separated list e.g. '-u root,nobody' or
blank-separated list e.g. '-p 123 4567'

Output formats:
-F extra full
-f full-format, including command lines
f, --forest ascii art process tree
-H show process hierarchy
-j jobs format
j BSD job control format
-l long format
l BSD long format
-M, Z add security data (for SE Linux)
-O <format> preloaded with default columns
O <format> as -O, with BSD personality
-o, o, --format <format>
user defined format
s signal format
u user-oriented format
v virtual memory format
X register format
-y do not show flags, show rrs vs. addr (used with -l)
--context display security context (for SE Linux)
--headers repeat header lines, one per page
--no-headers do not print header at all
--cols, --columns, --width <num>
set screen width
--rows, --lines <num>
set screen height

Show threads:
H as if they where processes
-L possibly with LWP and NLWP columns
-m, m after processes
-T possibly with SPID column

Miscellaneous options:
-c show scheduling class with -l option
c show true command name
e show the environment after command
k, --sort specify sort order as: [+|-]key[,[+|-]key[,...]]
L list format specifiers
n display numeric uid and wchan
S, --cumulative include some dead child process data
-y do not show flags, show rss (only with -l)
-V, V, --version display version information and exit
-w, w unlimited output width

--help <simple|list|output|threads|misc|all>
display help and exit

The_ouroboros
29-01-2013, 15:20
su top, lo digiti su cli e poi cerchi a occhio dov'è il prog. (htop è più grafico)
Trovi info su memoria e cpu occupate.
Su ps vedi info su pid e interdipendenze, con ps ef

The_ouroboros
29-01-2013, 15:22
e con strace (o truss) puoi seguire, con il PID, le chiamate di sistema di ogni processo ( a cui hai accesso con UID/GID)

Vincenzo1968
29-01-2013, 15:30
Questo è l'output di top mentre eseguo il mio programma per il contest 19 punto B.1:

http://img171.imageshack.us/img171/4006/topvincenzo1968.jpg

E con ps invece? c'aggià fà?

The_ouroboros
29-01-2013, 15:33
ps ti da PID e varie dipendenze.
Con ef hai un tree di come sono graticamente.

Vincenzo1968
29-01-2013, 15:35
ps ti da PID e varie dipendenze.
Con ef hai un tree di come sono graticamente.

Ah quindi, come con top, eseguo ps e poi lancio il mio programma da un secondo terminale?

Vincenzo1968
29-01-2013, 15:38
ps mi da un fottiò di righe:


UID PID PPID C STIME TTY TIME CMD
root 1 0 0 13:26 ? 00:00:00 /sbin/init
root 2 0 0 13:26 ? 00:00:00 [kthreadd]
root 3 2 0 13:26 ? 00:00:06 [ksoftirqd/0]
root 6 2 0 13:26 ? 00:00:00 [migration/0]
root 7 2 0 13:26 ? 00:00:00 [watchdog/0]
root 8 2 0 13:26 ? 00:00:00 [migration/1]
root 10 2 0 13:26 ? 00:00:07 [ksoftirqd/1]
root 11 2 0 13:26 ? 00:00:00 [watchdog/1]
root 12 2 0 13:26 ? 00:00:00 [cpuset]
root 13 2 0 13:26 ? 00:00:00 [khelper]
root 14 2 0 13:26 ? 00:00:00 [kdevtmpfs]
root 15 2 0 13:26 ? 00:00:00 [netns]
root 16 2 0 13:26 ? 00:00:00 [kworker/u:1]
root 17 2 0 13:26 ? 00:00:00 [sync_supers]
root 18 2 0 13:26 ? 00:00:00 [bdi-default]
root 19 2 0 13:26 ? 00:00:00 [kintegrityd]
root 20 2 0 13:26 ? 00:00:00 [kblockd]
root 21 2 0 13:26 ? 00:00:00 [ata_sff]
root 22 2 0 13:26 ? 00:00:00 [khubd]
root 23 2 0 13:26 ? 00:00:00 [md]
root 26 2 0 13:26 ? 00:00:00 [khungtaskd]
root 27 2 0 13:26 ? 00:00:00 [kswapd0]
root 28 2 0 13:26 ? 00:00:00 [ksmd]
root 29 2 0 13:26 ? 00:00:00 [khugepaged]
root 30 2 0 13:26 ? 00:00:00 [fsnotify_mark]
root 31 2 0 13:26 ? 00:00:00 [ecryptfs-kthrea]
root 32 2 0 13:26 ? 00:00:00 [crypto]
root 41 2 0 13:26 ? 00:00:00 [kthrotld]
root 42 2 0 13:26 ? 00:00:00 [scsi_eh_0]
root 43 2 0 13:26 ? 00:00:00 [scsi_eh_1]
root 44 2 0 13:26 ? 00:00:00 [scsi_eh_2]
root 45 2 0 13:26 ? 00:00:00 [scsi_eh_3]
root 48 2 0 13:26 ? 00:00:00 [kworker/u:4]
root 50 2 0 13:26 ? 00:00:00 [binder]
root 70 2 0 13:26 ? 00:00:00 [deferwq]
root 71 2 0 13:26 ? 00:00:00 [charger_manager]
root 72 2 0 13:26 ? 00:00:00 [devfreq_wq]
root 214 2 0 13:26 ? 00:00:00 [scsi_eh_4]
root 216 2 0 13:26 ? 00:00:00 [scsi_eh_5]
root 238 2 0 13:26 ? 00:00:00 [kdmflush]
root 240 2 0 13:26 ? 00:00:00 [kdmflush]
root 255 2 0 13:26 ? 00:00:00 [jbd2/dm-0-8]
root 256 2 0 13:26 ? 00:00:00 [ext4-dio-unwrit]
root 274 2 0 13:26 ? 00:00:00 [flush-252:0]
root 547 1 0 13:26 ? 00:00:00 upstart-udev-bridge --daemon
root 566 1 0 13:26 ? 00:00:00 /sbin/udevd --daemon
102 571 1 0 13:26 ? 00:00:00 dbus-daemon --system --fork
root 595 1 0 13:26 ? 00:00:00 /usr/sbin/bluetoothd
syslog 625 1 0 13:26 ? 00:00:01 rsyslogd -c5
avahi 627 1 0 13:26 ? 00:00:00 avahi-daemon: running [Ubuntu12-
avahi 628 627 0 13:26 ? 00:00:00 avahi-daemon: chroot helper
root 643 2 0 13:26 ? 00:00:00 [krfcommd]
root 686 1 0 13:26 ? 00:00:00 /usr/sbin/cupsd -F
root 700 2 0 13:26 ? 00:00:00 [ttm_swap]
root 727 2 0 13:26 ? 00:00:00 [kpsmoused]
root 731 2 0 13:26 ? 00:00:00 [edac-poller]
root 738 2 0 13:26 ? 00:00:00 [kvm-irqfd-clean]
root 811 2 0 13:26 ? 00:00:00 [hd-audio0]
root 871 1 0 13:26 ? 00:00:00 /usr/sbin/modem-manager
root 883 1 0 13:26 ? 00:00:00 NetworkManager
root 893 1 0 13:26 ? 00:00:00 /usr/lib/policykit-1/polkitd --n
root 902 1 0 13:26 ? 00:00:00 upstart-socket-bridge --daemon
root 986 1 0 13:26 tty4 00:00:00 /sbin/getty -8 38400 tty4
root 995 1 0 13:26 tty5 00:00:00 /sbin/getty -8 38400 tty5
root 1011 1 0 13:26 tty2 00:00:00 /sbin/getty -8 38400 tty2
root 1013 1 0 13:26 tty3 00:00:00 /sbin/getty -8 38400 tty3
root 1016 1 0 13:26 tty6 00:00:00 /sbin/getty -8 38400 tty6
root 1048 1 0 13:26 ? 00:00:00 acpid -c /etc/acpi/events -s /va
whoopsie 1049 1 0 13:26 ? 00:00:00 whoopsie
root 1068 1 0 13:26 ? 00:00:00 /usr/sbin/irqbalance
root 1073 1 0 13:26 ? 00:00:00 cron
daemon 1074 1 0 13:26 ? 00:00:00 atd
root 1110 1 0 13:26 ? 00:00:00 lightdm
mysql 1138 1 0 13:26 ? 00:00:12 /usr/sbin/mysqld
root 1191 1110 6 13:26 tty7 00:08:53 /usr/bin/X :0 -core -auth /var/r
postgres 1231 1 0 13:26 ? 00:00:00 /usr/lib/postgresql/9.1/bin/post
root 1251 1 0 13:26 ? 00:00:00 /usr/lib/accountsservice/account
root 1269 1 0 13:26 ? 00:00:00 /usr/sbin/console-kit-daemon --n
root 1353 883 0 13:26 ? 00:00:00 /sbin/dhclient -d -4 -sf /usr/li
root 1417 1 0 13:26 ? 00:00:00 /usr/lib/upower/upowerd
postgres 1448 1231 0 13:26 ? 00:00:01 postgres: writer process
postgres 1449 1231 0 13:26 ? 00:00:01 postgres: wal writer process
postgres 1451 1231 0 13:26 ? 00:00:00 postgres: autovacuum launcher pr
postgres 1452 1231 0 13:26 ? 00:00:00 postgres: stats collector proces
root 1477 1110 0 13:26 ? 00:00:00 lightdm --session-child 12 21
colord 1575 1 0 13:26 ? 00:00:00 /usr/lib/x86_64-linux-gnu/colord
rtkit 1656 1 0 13:26 ? 00:00:00 /usr/lib/rtkit/rtkit-daemon
lightdm 1746 1 0 13:26 ? 00:00:00 /usr/lib/evolution/evolution-cal
nobody 1758 883 0 13:27 ? 00:00:01 /usr/sbin/dnsmasq --no-resolv --
root 1856 1 0 13:27 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1879 1856 0 13:27 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1880 1856 0 13:27 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1881 1856 0 13:27 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1882 1856 0 13:27 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 1883 1856 0 13:27 ? 00:00:00 /usr/sbin/apache2 -k start
root 1902 1 0 13:27 tty1 00:00:00 /sbin/getty -8 38400 tty1
vincenzo 2041 1 0 13:27 ? 00:00:00 /usr/bin/gnome-keyring-daemon --
vincenzo 2052 1477 0 13:27 ? 00:00:00 gnome-session --session=ubuntu
vincenzo 2088 2052 0 13:27 ? 00:00:00 /usr/bin/ssh-agent /usr/bin/dbus
vincenzo 2091 1 0 13:27 ? 00:00:00 /usr/bin/dbus-launch --exit-with
vincenzo 2092 1 0 13:27 ? 00:00:05 //bin/dbus-daemon --fork --print
vincenzo 2094 1 0 13:27 ? 00:00:00 /usr/lib/at-spi2-core/at-spi-bus
vincenzo 2098 2094 0 13:27 ? 00:00:00 /bin/dbus-daemon --config-file=/
vincenzo 2101 1 0 13:27 ? 00:00:02 /usr/lib/at-spi2-core/at-spi2-re
vincenzo 2114 2052 0 13:27 ? 00:00:05 /usr/lib/gnome-settings-daemon/g
vincenzo 2120 1 0 13:27 ? 00:00:00 /usr/lib/gvfs/gvfsd
vincenzo 2124 1 0 13:27 ? 00:00:00 /usr/lib/gvfs//gvfsd-fuse -f /ru
vincenzo 2137 2052 3 13:27 ? 00:04:15 compiz
vincenzo 2143 1 0 13:27 ? 00:00:00 /usr/lib/dconf/dconf-service
vincenzo 2151 1 0 13:27 ? 00:00:01 /usr/bin/pulseaudio --start --lo
vincenzo 2153 2052 0 13:27 ? 00:00:00 nm-applet
vincenzo 2154 2052 0 13:27 ? 00:00:00 bluetooth-applet
vincenzo 2155 2052 0 13:27 ? 00:00:00 /usr/lib/policykit-1-gnome/polki
vincenzo 2156 2052 0 13:27 ? 00:00:00 /usr/lib/gnome-settings-daemon/g
vincenzo 2159 2151 0 13:27 ? 00:00:00 /usr/lib/pulseaudio/pulse/gconf-
vincenzo 2161 1 0 13:27 ? 00:00:00 /usr/lib/x86_64-linux-gnu/gconf/
vincenzo 2185 1 0 13:27 ? 00:00:00 /usr/lib/gvfs/gvfs-udisks2-volum
root 2189 1 0 13:27 ? 00:00:00 /usr/lib/udisks2/udisksd --no-de
vincenzo 2198 1 0 13:27 ? 00:00:00 /usr/lib/gvfs/gvfs-gphoto2-volum
vincenzo 2204 1 0 13:27 ? 00:00:00 /usr/lib/gvfs/gvfs-afc-volume-mo
vincenzo 2214 1 0 13:27 ? 00:00:00 /usr/lib/gvfs/gvfsd-trash --spaw
vincenzo 2224 1 0 13:27 ? 00:00:00 /usr/lib/gvfs/gvfsd-burn --spawn
vincenzo 2232 1 0 13:27 ? 00:00:06 /usr/lib/bamf/bamfdaemon
vincenzo 2236 2137 0 13:27 ? 00:00:00 /bin/sh -c /usr/bin/gtk-window-d
vincenzo 2237 2236 0 13:27 ? 00:00:04 /usr/bin/gtk-window-decorator
vincenzo 2250 1 0 13:27 ? 00:00:18 /usr/lib/unity/unity-panel-servi
vincenzo 2252 1 0 13:27 ? 00:00:08 /usr/lib/indicator-appmenu/hud-s
vincenzo 2266 1 0 13:27 ? 00:00:00 /usr/lib/indicator-sound/indicat
vincenzo 2270 1 0 13:27 ? 00:00:00 /usr/lib/indicator-datetime/indi
vincenzo 2271 1 0 13:27 ? 00:00:00 /usr/lib/indicator-messages/indi
vincenzo 2274 1 0 13:27 ? 00:00:00 /usr/lib/x86_64-linux-gnu/indica
vincenzo 2275 1 0 13:27 ? 00:00:00 /usr/lib/indicator-printers/indi
vincenzo 2276 1 0 13:27 ? 00:00:00 /usr/lib/indicator-session/indic
vincenzo 2303 1 0 13:27 ? 00:00:00 /usr/lib/evolution/evolution-sou
vincenzo 2320 1 0 13:27 ? 00:00:00 /usr/lib/gnome-online-accounts/g
vincenzo 2326 1 0 13:27 ? 00:00:00 /usr/lib/geoclue/geoclue-master
vincenzo 2341 1 0 13:27 ? 00:00:00 /usr/lib/ubuntu-geoip/ubuntu-geo
vincenzo 2351 2052 0 13:27 ? 00:00:00 telepathy-indicator
vincenzo 2357 1 0 13:27 ? 00:00:00 /usr/lib/telepathy/mission-contr
vincenzo 2364 1 0 13:27 ? 00:00:00 /usr/bin/signon-ui
vincenzo 2368 2052 0 13:27 ? 00:00:03 zeitgeist-datahub
vincenzo 2374 1 0 13:27 ? 00:00:00 /usr/bin/zeitgeist-daemon
vincenzo 2380 1 0 13:27 ? 00:00:00 /usr/lib/zeitgeist/zeitgeist-fts
vincenzo 2388 2380 0 13:27 ? 00:00:00 /bin/cat
vincenzo 2401 1 0 13:27 ? 00:00:02 /usr/bin/python /usr/lib/ubuntuo
vincenzo 2449 1 0 13:27 ? 00:00:49 nautilus trash://
vincenzo 2461 1 0 13:27 ? 00:00:00 /usr/lib/unity-lens-applications
vincenzo 2465 1 0 13:27 ? 00:00:00 /usr/lib/unity-lens-files/unity-
vincenzo 2467 1 0 13:27 ? 00:00:00 /usr/lib/gwibber/unity-gwibber-d
vincenzo 2470 1 0 13:27 ? 00:00:00 /usr/lib/x86_64-linux-gnu/unity-
vincenzo 2472 1 0 13:27 ? 00:00:00 /usr/bin/python3 /usr/lib/unity-
vincenzo 2473 1 0 13:27 ? 00:00:00 /usr/lib/x86_64-linux-gnu/unity-
vincenzo 2475 1 0 13:27 ? 00:00:00 /usr/bin/python /usr/lib/unity-l
vincenzo 2540 1 0 13:27 ? 00:00:00 /usr/lib/gvfs/gvfsd-metadata
vincenzo 2558 1 0 13:27 ? 00:00:00 /usr/lib/x86_64-linux-gnu/unity-
vincenzo 2560 1 0 13:27 ? 00:00:00 /usr/bin/python3 /usr/lib/unity-
vincenzo 2561 1 0 13:27 ? 00:00:00 /usr/bin/python /usr/lib/unity-s
vincenzo 2599 2052 0 13:28 ? 00:00:00 update-notifier
root 2678 566 0 13:29 ? 00:00:00 /sbin/udevd --daemon
root 2679 566 0 13:29 ? 00:00:00 /sbin/udevd --daemon
vincenzo 2684 2052 0 13:29 ? 00:00:00 /usr/lib/x86_64-linux-gnu/deja-d
vincenzo 2715 1 0 13:29 ? 00:00:00 /usr/lib/libunity-webapps/unity-
vincenzo 4064 1 35 14:44 ? 00:18:20 /usr/lib/firefox/firefox
vincenzo 4260 1 0 14:57 ? 00:00:06 gnome-terminal
vincenzo 4269 4260 0 14:57 ? 00:00:00 gnome-pty-helper
vincenzo 4368 1 0 15:01 ? 00:00:00 kdeinit4: kdeinit4 Running...
vincenzo 4371 4368 0 15:01 ? 00:00:00 kdeinit4: klauncher [kdeinit] --
vincenzo 4373 1 0 15:01 ? 00:00:00 kdeinit4: kded4 [kdeinit]
root 4380 1 0 15:01 ? 00:00:00 /usr/lib/udisks/udisks-daemon
root 4381 4380 0 15:01 ? 00:00:00 udisks-daemon: not polling any d
vincenzo 4389 1 0 15:01 ? 00:00:01 /usr/bin/knotify4
vincenzo 4393 1 0 15:01 ? 00:00:00 /usr/lib/notify-osd/notify-osd
vincenzo 4436 4064 3 15:02 ? 00:01:17 /usr/lib/firefox/plugin-containe
root 4650 2 0 15:20 ? 00:00:01 [kworker/0:1]
root 4652 2 0 15:22 ? 00:00:01 [kworker/1:2]
vincenzo 4683 4260 0 15:25 pts/2 00:00:00 bash
root 4737 2 0 15:26 ? 00:00:01 [kworker/0:2]
root 4762 2 0 15:27 ? 00:00:00 [kworker/1:1]
root 4833 2 0 15:31 ? 00:00:00 [kworker/0:0]
vincenzo 4901 4260 0 15:36 pts/1 00:00:00 bash
vincenzo 4951 4901 0 15:36 pts/1 00:00:00 ps -ef

The_ouroboros
29-01-2013, 15:41
ti do un esempio del mio ps ef cosi capisci meglio


PID TTY STAT TIME COMMAND
3674 tty1 S 0:00 -bash TERM=linux HOME=/home/lucas SHELL=/bin/bash USER=lucas LOGNAME=lucas PATH=/usr/local/bin:
3759 tty1 S+ 0:00 \_ /bin/sh /usr/bin/startx SHELL=/bin/bash TERM=linux XDG_SESSION_COOKIE=
3776 tty1 S+ 0:00 \_ xinit /etc/X11/xinit/xinitrc -- /etc/X11/xinit/xserverrc :0 -auth /tmp/serverauth.CbM2y
3785 tty1 S 0:00 \_ /usr/bin/ck-launch-session /usr/bin/dbus-launch --exit-with-session x-session-manag
3821 tty1 S 0:00 \_ /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserverrc MAIL=/var/mail/lucas
3839 tty1 S 0:02 \_ xscreensaver -no-splash MAIL=/var/mail/lucas USER=lucas SSH_AGENT_PID=3812
3841 tty1 Sl 0:02 \_ xfce4-session MAIL=/var/mail/lucas USER=lucas SSH_AGENT_PID=3812 SHLVL=1 PE
3850 tty1 S 0:03 \_ xfwm4 --display :0.0 --sm-client-id 2b0ef8c8e-4323-46a8-9302-b9cd5dd23c
3855 tty1 Sl 0:02 \_ Thunar --sm-client-id
3860 tty1 Sl 0:09 \_ xfce4-panel --display :0.0 --sm-client-id
3879 tty1 S 0:00 | \_ /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper /usr/lib/x86_64-linux
3886 tty1 S 1:48 | \_ /usr/lib/x86_64-linux-gnu/xfce4/panel-plugins/xfce4-netload-plugin
3887 tty1 S 0:01 | \_ /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper /usr/lib/x86_64-linux
3888 tty1 Sl 0:00 | \_ /usr/lib/x86_64-linux-gnu/xfce4/panel-plugins/xfce4-mixer-plugin 1
3861 tty1 Sl 0:01 \_ xfdesktop --display :0.0 --sm-client-id
4295 tty1 SLl 7:26 \_ /usr/lib/chromium/chromium --password-store=detect
4299 tty1 S 0:06 \_ /usr/lib/chromium/chromium --password-store=detect
4300 tty1 S 0:00 \_ /usr/lib/chromium/chromium-sandbox /usr/lib/chromium/chromium -
4302 tty1 S 0:00 | \_ /usr/lib/chromium/chromium --type=zygote
4305 tty1 S 0:00 | \_ /usr/lib/chromium/chromium --type=zygote
4325 tty1 Sl 2:30 | \_ /usr/lib/chromium/chromium --type=renderer --lang=e
4329 tty1 Sl 0:18 | \_ /usr/lib/chromium/chromium --type=renderer --lang=e
18969 tty1 Sl 0:15 | \_ /usr/lib/chromium/chromium --type=renderer --lang=e
21383 tty1 Sl 0:04 | \_ /usr/lib/chromium/chromium --type=renderer --lang=e
25423 tty1 Sl 0:00 | \_ /usr/lib/chromium/chromium --type=renderer --lang=e
25431 tty1 Sl 0:02 | \_ /usr/lib/chromium/chromium --type=renderer --lang=e
4400 tty1 Sl 0:01 \_ /usr/lib/chromium/chromium --type=plugin --plugin-path=/home/lu
23725 tty1 Sl 0:00 xfce4-terminal MAIL=/var/mail/lucas USER=lucas SSH_AGENT_PID=3812 SHLVL=1 PERL_LOCAL_LIB_ROOT=/
23726 tty1 S 0:00 \_ gnome-pty-helper
23727 pts/0 Ss 0:00 \_ bash PERL_LOCAL_LIB_ROOT=/home/lucas/perl5 XDG_CONFIG_DIRS=/etc/xdg HUSHLOGIN=FALSE SHLVL=1
25475 pts/0 R+ 0:00 \_ ps ef SSH_AGENT_PID=3812 GPG_AGENT_INFO=/home/lucas/.cache/keyring-yMDiWe/gpg:0:1 GLADE
3890 tty1 Sl 0:00 /usr/lib/notification-daemon/notification-daemon MAIL=/var/mail/lucas USER=lucas SSH_AGENT_PID=
3884 tty1 S 0:00 /usr/bin/python -O /usr/share/wicd/gtk/wicd-client.py --tray GNOME_KEYRING_PID=3848 MAIL=/var/m
3878 tty1 Sl 0:00 /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 MAIL=/var/mail/lucas USER=lucas
3864 tty1 S 0:00 xfce4-settings-helper --display :0.0 --sm-client-id MAIL=
3848 tty1 SLl 0:02 gnome-keyring-daemon --start
3846 tty1 S 0:00 xfsettingsd --force MAIL=/var/mail/lucas USER=lucas SSH_AGENT_PID=3812 SHLVL=1 PERL_LOCAL_LIB_R
3824 tty1 S 0:00 /usr/bin/dbus-launch --exit-with-session x-session-manager MAIL=/var/mail/lucas USER=lucas SHLV


Con il PID (prima colonna) e strace puoi anche seguire le syscall che fa il tuo programma.

Es (chromium (chrome non da google)) con PID 4295

recvfrom(8, 0x7f922677c0f4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
write(44, "\0", 1) = 1
poll([{fd=8, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=8, revents=POLLOUT}])
writev(8, [{"\225\7\2\0/\333\t\0036\0\2\0.\333\t\3(\4\4\0\235\216\t\3\257\0\0\0\0\0\0\0", 32}, {NULL, 0}, {"", 0}], 3) = 32
poll([{fd=8, events=POLLIN}], 1, -1) = 1 ([{fd=8, revents=POLLIN}])
recvfrom(8, "\1\1\3727\0\0\0\0\253\217\340\0\0\0q\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096, 0, NULL, NULL) = 32
recvfrom(8, 0x7f922677c0f4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=8, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=8, revents=POLLOUT}])
writev(8, [{">\7\7\0\343\216\t\3\235\216\t\3\345\216\t\3\0\0\0\0\0\0\0\0\0\0\0\0(\0\4\0"..., 44}, {NULL, 0}, {"", 0}], 3) = 44
poll([{fd=8, events=POLLIN}], 1, -1) = 1 ([{fd=8, revents=POLLIN}])
recvfrom(8, "\16\0\3737\235\216\t\3\0\0>\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 0, NULL, NULL) = 64
recvfrom(8, 0x7f922677c0f4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=8, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=8, revents=POLLOUT}])
writev(8, [{">\7\7\0\343\216\t\3\235\216\t\3\345\216\t\3\316\4[\1\316\4[\1%\0<\0(\0\4\0"..., 44}, {NULL, 0}, {"", 0}], 3) = 44
poll([{fd=8, events=POLLIN}], 1, -1) = 1 ([{fd=8, revents=POLLIN}])
recvfrom(8, "\16\0\3757\235\216\t\3\0\0>\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 0, NULL, NULL) = 64
recvfrom(8, 0x7f922677c0f4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=9, events=POLLIN}, {fd=8, events=POLLIN}, {fd=66, events=POLLIN}, {fd=97, events=POLLIN}, {fd=94, events=POLLIN}, {fd=78, events=POLLIN}], 6, 0) = 0 (Timeout)
poll([{fd=8, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=8, revents=POLLOUT}])
writev(8, [{">\7\7\0\343\216\t\3\235\216\t\3\345\216\t\3{\4\344\1{\4\344\1$\0\"\0", 28}, {NULL, 0}, {"", 0}], 3) = 28
recvfrom(8, "\16\0\3777\235\216\t\3\0\0>\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 4096, 0, NULL, NULL) = 32
recvfrom(8, 0x7f922677c0f4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=9, events=POLLIN}, {fd=8, events=POLLIN}, {fd=66, events=POLLIN}, {fd=97, events=POLLIN}, {fd=94, events=POLLIN}, {fd=78, events=POLLIN}], 6, 0) = 0 (Timeout)
recvfrom(8, 0x7f922677c0f4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=9, events=POLLIN}, {fd=8, events=POLLIN}, {fd=66, events=POLLIN}, {fd=97, events=POLLIN}, {fd=94, events=POLLIN}, {fd=78, events=POLLIN}, {fd=10, events=POLLIN}], 7, 0) = 0 (Timeout)
recvfrom(8, 0x7f922677c0f4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=9, events=POLLIN}, {fd=8, events=POLLIN}, {fd=66, events=POLLIN}, {fd=97, events=POLLIN}, {fd=94, events=POLLIN}, {fd=78, events=POLLIN}, {fd=10, events=POLLIN}], 7, 0) = 0 (Timeout)
recvfrom(8, 0x7f922677c0f4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=9, events=POLLIN}, {fd=8, events=POLLIN}, {fd=66, events=POLLIN}, {fd=97, events=POLLIN}, {fd=94, events=POLLIN}, {fd=78, events=POLLIN}, {fd=10, events=POLLIN}], 7, 748^C <unfini

Vincenzo1968
29-01-2013, 15:44
Grazie mille Ouro. E grazie mille Sottovento.

I vostri link è suggerimenti sono preziosi per me.

;)

The_ouroboros
29-01-2013, 15:55
Grazie mille Ouro. E grazie mille Sottovento.

I vostri link è suggerimenti sono preziosi per me.

;)

felice di averti aiutato almeno un pò. :D

Vincenzo1968
29-01-2013, 16:04
Ho trovato anche un bell'articolo su top e ps:

http://www.drdobbs.com/open-source/performance-analysis-tools-for-linux-dev/220700195

:yeah: :winner: :yeah:

EDIT: e anche questo:

http://linux.die.net/man/1/atop

;)

Vincenzo1968
29-01-2013, 16:18
Su Linux/GCC c'è anche gprof:

http://www.drdobbs.com/open-source/performance-analysis-tools-for-linux-dev/220700195?pgno=2

:yeah: :winner: :yeah:

EDIT: ma bisogna avere i sorgenti e compilare con l'opzione -pg.

The_ouroboros
29-01-2013, 16:23
Su Linux/GCC c'è anche gprof:

http://www.drdobbs.com/open-source/performance-analysis-tools-for-linux-dev/220700195?pgno=2

:yeah: :winner: :yeah:

EDIT: ma bisogna avere i sorgenti e compilare con l'opzione -pg.

con solo -g puoi usare gdb :D

Vincenzo1968
29-01-2013, 16:25
con solo -g puoi usare gdb :D

Si, gdb l'ho già utilizzato. Ma funziona anche come profiler?

Vincenzo1968
29-01-2013, 16:32
C'è da dire che Linux mi piace sempre più. Ci sono un fottìo di tools già installati.

Su Windows se non era per Mark Russinovich(programmatore coi controcabasisi)... A meno che non esistano un sacco di altri strumenti che non conosco(il che non è affatto improbabile).

:D

The_ouroboros
29-01-2013, 16:35
Si, gdb l'ho già utilizzato. Ma funziona anche come profiler?

http://readwrite.com/2010/11/01/using-gdb-as-a-poor-mans-profi

Vincenzo1968
29-01-2013, 16:39
vincenzo@Ubuntu12-10-AMD64:~$ atop --version
Il programma "atop" non è attualmente installato. È possibile installarlo digitando:
sudo apt-get install atop
vincenzo@Ubuntu12-10-AMD64:~$ sudo apt-get install atop
[sudo] password for vincenzo:
Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze
Lettura informazioni sullo stato... Fatto
I seguenti pacchetti sono stati installati automaticamente e non sono più richiesti:
calligra-l10n-engb calligra-l10n-it cdparanoia cpp-4.5 e17-data
evas-generic-loaders gcc-4.5-base k3b k3b-data k3b-i18n language-pack-kde-en
language-pack-kde-it lib32gcc1-dbg libecore1 libedbus1 libedje1 libeet-bin
libeet1 libeeze1 libefreet1 libeina1 libeio0 libelfg0 libembryo0 libevas1
libflac++6 libk3b6 libkcddb4 libxcb-keysyms1 linux-headers-3.5.0-17
Usare "apt-get autoremove" per rimuoverli.
I seguenti pacchetti NUOVI saranno installati:
atop
0 aggiornati, 1 installati, 0 da rimuovere e 0 non aggiornati.
È necessario scaricare 169 kB di archivi.
Dopo quest'operazione, verranno occupati 492 kB di spazio su disco.
Scaricamento di:1 http://it.archive.ubuntu.com/ubuntu/ quantal/universe atop amd64 1.26-0ubuntu1 [169 kB]
Recuperati 169 kB in 0s (291 kB/s)
Selezionato il pacchetto atop non precedentemente selezionato.
(Lettura del database... 342756 file e directory attualmente installati.)
Estrazione di atop (da .../atop_1.26-0ubuntu1_amd64.deb)...
Elaborazione dei trigger per man-db...
Elaborazione dei trigger per ureadahead...
ureadahead will be reprofiled on next reboot
Configurazione di atop (1.26-0ubuntu1)...
Starting atop system monitor: atop.
Elaborazione dei trigger per ureadahead...
vincenzo@Ubuntu12-10-AMD64:~$ atop --version
atop: invalid option -- '-'
Usage: atop [-flags] [interval [samples]]
or
Usage: atop -w file [-S] [-a] [interval [samples]]
atop -r [file] [-b hh:mm] [-e hh:mm] [-flags]

generic flags:
-a show or log all processes (i.s.o. active processes only)
-P generate parseable output for specified label(s)
-L alternate line length (default 80) in case of non-screen output
-f show fixed number of lines with system-statistics
-l show limited number of lines for certain resources
-1 show average-per-second i.s.o. total values

-x no colors in case of high occupation
-g show general process-info (default)
-m show memory-related process-info
-d show disk-related process-info
-n show network-related process-info
-s show scheduling-related process-info
-v show various process-info (ppid, user/group, date/time)
-c show command-line per process
-o show own defined process-info
-u show cumulated process-info per user
-p show cumulated process-info per program (i.e. same name)

-C sort processes in order of cpu-consumption (default)
-M sort processes in order of memory-consumption
-D sort processes in order of disk-activity
-N sort processes in order of network-activity
-A sort processes in order of most active resource (auto mode)

specific flags for raw logfiles:
-w write raw data to file (compressed)
-r read raw data from file (compressed)
special file: y[y...] for yesterday (repeated)
-S finish atop automatically before midnight (i.s.o. #samples)
-b begin showing data from specified time
-e finish showing data after specified time

interval: number of seconds (minimum 0)
samples: number of intervals (minimum 1)

If the interval-value is zero, a new sample can be
forced manually by sending signal USR1 (kill -USR1 pid_atop)
or with the keystroke 't' in interactive mode.


http://www.hwupgrade.org/public/style_emoticons/default/coolface.png

Vincenzo1968
29-01-2013, 16:42
http://readwrite.com/2010/11/01/using-gdb-as-a-poor-mans-profi

http://img33.imageshack.us/img33/5121/gdbprofiler.jpg

Ancora una volta grazie mille mio preziosissimo amico ;)

The_ouroboros
29-01-2013, 16:44
era la summa dei prog che ti ho suggerito in questo post :D

WarDuck
30-01-2013, 21:25
Prova anche htop ;).

Vincenzo1968
30-01-2013, 22:36
http://htop.sourceforge.net/

Grazie :D

Su Linux c'è solo l'imbarazzo della scelta :D

tomminno
30-01-2013, 22:43
C'è da dire che Linux mi piace sempre più. Ci sono un fottìo di tools già installati.

Su Windows se non era per Mark Russinovich(programmatore coi controcabasisi)... A meno che non esistano un sacco di altri strumenti che non conosco(il che non è affatto improbabile).

:D

Il primo che mi viene in mente su Windows è banalmente il Task Manager...

Vincenzo1968
31-01-2013, 00:33
Il primo che mi viene in mente su Windows è banalmente il Task Manager...

Io banalmente non lo conoscevo, nonostante vent'anni di utilizzo Windows, perché, programmando in C, le mie applicazioni sono sempre state efficienti e dal punto di vista della velocità di esecuzione e dal punto di vista delle risorse di memoria utilizzate.

Adesso ho chiesto perché volevo misurare l'occupazione di memoria dei vari programmi presentati per il contest19.

Grazie per la segnalazione ;)

WarDuck
31-01-2013, 12:16
Io banalmente non lo conoscevo, nonostante vent'anni di utilizzo Windows, perché, programmando in C, le mie applicazioni sono sempre state efficienti e dal punto di vista della velocità di esecuzione e dal punto di vista delle risorse di memoria utilizzate.

Adesso ho chiesto perché volevo misurare l'occupazione di memoria dei vari programmi presentati per il contest19.

Grazie per la segnalazione ;)

Diciamo che se un applicazione fa il suo lavoro in un tempo accettabile, allora è efficiente (per fare quel lavoro).

PS: misurare solo una cosa non ha senso comunque eh, occhio ai tradeoff tempo/spazio.

Posso essere estremamente efficiente in termini di memoria consumata, e perdere in prestazioni complessive.

Esempio classico: tree vs hashtable.

Vincenzo1968
31-01-2013, 12:20
Diciamo che se un applicazione fa il suo lavoro in un tempo accettabile, allora è efficiente (per fare quel lavoro).

PS: misurare solo una cosa non ha senso comunque eh, occhio ai tradeoff tempo/spazio.

Posso essere estremamente efficiente in termini di memoria consumata, e perdere in prestazioni complessive.

Esempio classico: tree vs hashtable.

Grazie per le info e per i preziosi consigli ;)

Comunque ho risposto in tono polemico a Tommino perché ho l'impressione che ce l'abbia con me. Non m'è piaciuto quel "banalmente".

Se non è così, se ho avuto un'impressione del tutto errata, sinceramente mi scuso e chiedo umilmente venia.

;)