linux/tools/perf
Arnaldo Carvalho de Melo ee29be625b perf tools: Save some loops using perf_evlist__id2evsel
Since we already ask for PERF_SAMPLE_ID and use it to quickly find the
associated evsel, add handler func + data to struct perf_evsel to avoid
using chains of if(strcmp(event_name)) and also to avoid all the linear
list searches via trace_event_find.

To demonstrate the technique convert 'perf sched' to it:

 # perf sched record sleep 5m

And then:

 Performance counter stats for '/tmp/oldperf sched lat':

        646.929438 task-clock                #    0.999 CPUs utilized
                 9 context-switches          #    0.000 M/sec
                 0 CPU-migrations            #    0.000 M/sec
            20,901 page-faults               #    0.032 M/sec
     1,290,144,450 cycles                    #    1.994 GHz
   <not supported> stalled-cycles-frontend
   <not supported> stalled-cycles-backend
     1,606,158,439 instructions              #    1.24  insns per cycle
       339,088,395 branches                  #  524.151 M/sec
         4,550,735 branch-misses             #    1.34% of all branches

       0.647524759 seconds time elapsed

Versus:

 Performance counter stats for 'perf sched lat':

        473.564691 task-clock                #    0.999 CPUs utilized
                 9 context-switches          #    0.000 M/sec
                 0 CPU-migrations            #    0.000 M/sec
            20,903 page-faults               #    0.044 M/sec
       944,367,984 cycles                    #    1.994 GHz
   <not supported> stalled-cycles-frontend
   <not supported> stalled-cycles-backend
     1,442,385,571 instructions              #    1.53  insns per cycle
       308,383,106 branches                  #  651.195 M/sec
         4,481,784 branch-misses             #    1.45% of all branches

       0.474215751 seconds time elapsed

[root@emilia ~]#

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-1kbzpl74lwi6lavpqke2u2p3@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2011-11-28 17:57:40 -02:00
..
Documentation perf script: Add comm filtering option 2011-11-28 11:48:23 -02:00
arch perf tools: Make perf.data more self-descriptive (v8) 2011-10-07 17:01:24 -03:00
bench perf tool: Fix gcc 4.6.0 issues 2011-02-07 12:41:41 -02:00
config perf tools: git mv tools/perf/{features-tests.mak,config/} 2011-04-19 08:18:36 -03:00
python perf evlist: Store pointer to the cpu and thread maps 2011-01-31 12:40:52 -02:00
scripts perf script: Add drop monitor script 2011-09-29 16:41:37 -03:00
util perf tools: Save some loops using perf_evlist__id2evsel 2011-11-28 17:57:40 -02:00
.gitignore perf tools: Makefile: Remove various and sundry cruft 2011-02-18 07:43:06 -02:00
CREDITS
MANIFEST perf packaging: add memcpy to perf MANIFEST 2010-11-30 23:00:10 -02:00
Makefile perf tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02:00
builtin-annotate.c perf tools: make -C consistent across commands (for cpu list arg) 2011-11-28 11:45:53 -02:00
builtin-bench.c perf options: Type check all the remaining OPT_ variants 2010-05-17 16:22:41 -03:00
builtin-buildid-cache.c perf buildid: add perfconfig option to specify buildid cache dir 2010-06-05 09:34:04 -03:00
builtin-buildid-list.c perf buildid-list: Support showing the build id in an ELF file 2011-09-29 16:41:37 -03:00
builtin-diff.c perf tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02:00
builtin-evlist.c perf evlist: New command to list the names of events present in a perf.data file 2011-03-15 11:10:48 -03:00
builtin-help.c perf options: Type check all the remaining OPT_ variants 2010-05-17 16:22:41 -03:00
builtin-inject.c perf tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02:00
builtin-kmem.c perf tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02:00
builtin-kvm.c perf options: Type check all the remaining OPT_ variants 2010-05-17 16:22:41 -03:00
builtin-list.c perf list: Allow filtering list of events 2011-02-17 15:38:58 -02:00
builtin-lock.c perf tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02:00
builtin-probe.c perf tools: Eliminate duplicate code and use PATH_MAX consistently 2011-11-28 10:11:04 -02:00
builtin-record.c perf tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02:00
builtin-report.c perf tools: make -C consistent across commands (for cpu list arg) 2011-11-28 11:45:53 -02:00
builtin-sched.c perf tools: Save some loops using perf_evlist__id2evsel 2011-11-28 17:57:40 -02:00
builtin-script.c perf script: Add comm filtering option 2011-11-28 11:48:23 -02:00
builtin-stat.c perf evlist: Introduce perf_evlist__add_attrs 2011-11-28 10:24:43 -02:00
builtin-test.c perf tools: Simplify debugfs mountpoint handling code 2011-11-28 10:11:28 -02:00
builtin-timechart.c perf tools: Rename perf_event_ops to perf_tool 2011-11-28 10:39:28 -02:00
builtin-top.c perf top: Stop using globals for tool state 2011-11-28 10:39:44 -02:00
builtin.h perf tools: Make perf.data more self-descriptive (v8) 2011-10-07 17:01:24 -03:00
command-list.txt perf evlist: New command to list the names of events present in a perf.data file 2011-03-15 11:10:48 -03:00
design.txt perf: Fix few typos + cosmetics 2010-01-13 17:39:44 +01:00
perf-archive.sh perf buildid: add perfconfig option to specify buildid cache dir 2010-06-05 09:34:04 -03:00
perf.c perf tools: Simplify debugfs mountpoint handling code 2011-11-28 10:11:28 -02:00
perf.h perf record: Move 'group' to perf_event_ops 2011-11-28 10:36:27 -02:00