Tag Info

Hot answers tagged

40

just use time when you call the script. time yourscript.sh


16

Just call times without arguments upon exiting your script. With ksh or zsh, you can also use time instead. With zsh, time will also give you the wall clock time in addition to the user and system CPU time. To preserve the exit status of your script, you can make it: ret=$?; times; exit "$ret" Or you can also add a trap on EXIT: trap times EXIT That ...


12

There are several aspects to this question which have been addressed partially through other tools, but there doesn't appear to be a single tool that provides all the features you're looking for. iotop This tools shows which processes are consuming the most I/O. But it lacks options to show specific file names. $ sudo iotop Total DISK READ: 0.00 B/s ...


7

If time isn't an option, start=`date +%s` stuff end=`date +%s` runtime=$((end-start))


6

Not stock, but here are a few tool I have used before: primes (usually in your distributions games package) just simply fork off a few dozen and it will generate primes from now until forever. Stress: http://people.seas.harvard.edu/~apw/stress/ CPUBurn: http://patrickmylund.com/projects/cpuburn/


6

You could check for references to function mcount (or possibly _mcount or __mcount according to Implementation of Profiling). This function is necessary for profiling to work, and should be absent for non-profiled binaries. Something like: $ readelf -s someprog | egrep "\s(_+)?mcount\b" && echo "Profiling is on for someprog" The above works on a ...


5

You can use perf to access the hardware performance counters: $ perf stat -e dTLB-load-misses,iTLB-load-misses /path/to/command e.g. : $ perf stat -e dTLB-load-misses,iTLB-load-misses /bin/ls > /dev/null Performance counter stats for '/bin/ls': 5,775 dTLB-load-misses 1,059 ...


4

Start by using time as per Jon Lin's suggestion: $ time ls test test real 0m0.004s user 0m0.002s sys 0m0.002s You don't say what unix your scripts are running on but strace on linux, truss on Solaris/AIX, and I think tusc on hp-ux let you learn a lot about what a process is doing. I like strace's -c option to get a nice summary: ]$ strace -c ...


4

The "<not supported>" messages mean that your platform doesn't support some of the processor's performance monitoring unit (PMU) hardware counters, also called performance instrumentation counters (PICs), which perf uses. This typically happens in virtualized environments. On bare-metal, you should see these counters (unless you are on some exotic CPU ...


3

Based on the question and comments, you could look up the java running call stack via the jstack command: jstack processid If there are some threads waiting for a long time on some condition then it is most likely a deadlock. A deadlock might be rare on production grade code but common on experimental multithreaded code. In the former case, a rerun might ...


2

Try using Valgrind's cache grind profiler or perf or perf expert. All of these will give LastLevel cache details as L3 turns out to be in most of the cases. U need to load all these modules. *Command for executing:* *VALGRIND:* valgrind --tool=cachegrind ./exe PERFEXPERT: perfexpert_run_exp ./exe PERF: perf stat -e ... -e ./exe


2

If you are distributing the computations with MPI, then using an MPI-aware tool would give you more sensible results: with a distributed application, you might have issues of load imbalance, where one MPI process is idle waiting for data to come from other processes. If you happen to be profiling exactly that MPI process, your performance profile will be all ...


2

It's not exactly profiling, but you can trace your script as it runs. Put set -xv before the section you want to trace and set +xv after the section. set -x enables xtrace, which will show every line that executes. set -v enables verbose mode, which will also show lines that may have an effect, but are not executed, such as variable assignment. You can also ...


2

Check out the time command. You can use it to measure the time it takes to execute along with some other useful info like where the time is being spent.


2

The tricky part with that file system is it used an MTD device for storage which is neither a block nor character device. The YAFFS2 filesystem has a dummy MTD device that stores data in an in-memory virtual NAND Flash. You can probably borrow it and coach it into working with JFFS2, but I'm not sure how useful it will be for profiling when the virtual ...


2

I think the application you're looking for is called cpulimit. This isn't a command that's normally included with a system so you'll have to install it either via your distros package manager (Ubuntu/Debian) or from source. Ubuntu/Debian $ apt-cache search cpulimit cpulimit - tool for limiting the CPU usage of a process So installation would go like ...


2

Take a look at this article titled: perf Examples, it has a number of examples that show how you can make flame graphs such as this one:      The above graph can be generated as an interactive SVG file as well. The graph was generated using the FlameGraph tool. This is separate software from perf. A series of commands similar to this ...


2

I haven't gotten an answer yet but I did write this script (at the end) and it seems to do what I want. I haven't tested it on other systems and it's Linux-specific. Basically it just wraps around strace for 30 seconds, filtering for file related system calls and makes an effort to strip out the filename. It counts the number of occurrences of that file in ...


2

#!/bin/bash start=$(date +%s.%N) # HERE BE CODE end=$(date +%s.%N) runtime=$(python -c "print(${end} - ${start})") echo "Runtime was $runtime" Yes, this calls Python, but if you can live with that then this is quite a nice, terse solution.


2

I'm a bit late to the bandwagon, but wanted to post my solution (for sub-second precision) in case others happen to stumble upon this thread through searching. The output is in format of days, hours, minutes, and finally seconds: res1=$(date +%s.%N) # do stuff in here res2=$(date +%s.%N) dt=$(echo "$res2 - $res1" | bc) dd=$(echo "$dt/86400" | bc) ...


1

Another option is to use a slow hardware - some kind of inexpensive ARM-based board like Raspbery Pi or (slightly more powerful) Compulab Trimslice should do. They've got a limited amount of memory, slow CPU yet can run a full Linux system - Fedora, Debian, and a few other distros have an ARM version.


1

You can use iwatch Using iWatch iWatch is very simple to use, suppose you want to watch the change in /etc filesystem, you just need to run it in the console $ iwatch /etc and iwatch will tell you if something changes in this directory. And if you want to be notified per email: $ iwatch -m admin@smsgw.local /etc In this case, the admin will get email ...


1

Eventually found the answer. Kind of obvious and I'm a little ashamed I didn't think of it before. But here it goes: Bascially blktrace/blkparse are the commands we're looking for. This is the general idea I'm basing it off of, but I can pipe the output of blktrace to blkparse then save blkparse's output to a file. Once the profiling is done I can look at ...


1

perf may be helpful for you. It is part of the linux kernel utilities. For instance: perf record -R -a -g fp -e cycles -e syscalls:sys_enter_poll -e syscalls:sys_exit_poll #Just ctrl+c if you are done, and view ith perf script It will show all syscall enter/exit times and parameters (like strace), provide the name of the binary invoking the syscall and ...


1

I can suggest you using SystemTap using which you can add probe points to a running linux kernel. It is similar to DTrace which is similar tool developed for Solaris. You can write simple stap script to perform interesting tasks.


1

I would look at the number of major page faults reported by "sar -B" the higher they are, then the more you're swapping. Here's an article that describes a few different methods.


1

Dunno whether it would be useful to you, but pidstat -r 1 -p 1 samples /sbin/init like this: 10:53:38 PID minflt/s majflt/s VSZ RSS %MEM Command 10:53:39 1 0.00 0.00 13648 1108 0.01 init 10:53:40 1 0.00 0.00 13648 1108 0.01 init 10:53:41 1 0.00 0.00 13648 ...


1

According to the Linux kernel source (namely, the file init/main.c), the ramdisk execute command is executed before init= and real_init=. This command is default to /init and can be configured via the rdinit= kernel command line parameter But to collect logs properly bootchartd need to be started without any parameters, so it looks like patching of ...


1

Some tools that might be of interest for you perf kcachegrind latencytop lttng


1

A minor fault and a TLB miss are not good analogues. A minor fault occurs when a requested page is in memory but is not mapped in the current page table. It would certainly be the case that a minor fault will be associated with a TLB miss (as the TLB entries are shortcuts to page table entries) but TLB misses will be caused by many other things eg hard ...



Only top voted, non community-wiki answers of a minimum length are eligible