aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/stat-cpi.py
blob: 01fa933ff3cf055d54e76aea1d31cfc730d35ab9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# SPDX-License-Identifier: GPL-2.0

from __future__ import print_function

data    = {}
times   = []
threads = []
cpus    = []

def get_key(time, event, cpu, thread):
    return "%d-%s-%d-%d" % (time, event, cpu, thread)

def store_key(time, cpu, thread):
    if (time not in times):
        times.append(time)

    if (cpu not in cpus):
        cpus.append(cpu)

    if (thread not in threads):
        threads.append(thread)

def store(time, event, cpu, thread, val, ena, run):
    #print("event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" %
    #      (event, cpu, thread, time, val, ena, run))

    store_key(time, cpu, thread)
    key = get_key(time, event, cpu, thread)
    data[key] = [ val, ena, run]

def get(time, event, cpu, thread):
    key = get_key(time, event, cpu, thread)
    return data[key][0]

def stat__cycles_k(cpu, thread, time, val, ena, run):
    store(time, "cycles", cpu, thread, val, ena, run);

def stat__instructions_k(cpu, thread, time, val, ena, run):
    store(time, "instructions", cpu, thread, val, ena, run);

def stat__cycles_u(cpu, thread, time, val, ena, run):
    store(time, "cycles", cpu, thread, val, ena, run);

def stat__instructions_u(cpu, thread, time, val, ena, run):
    store(time, "instructions", cpu, thread, val, ena, run);

def stat__cycles(cpu, thread, time, val, ena, run):
    store(time, "cycles", cpu, thread, val, ena, run);

def stat__instructions(cpu, thread, time, val, ena, run):
    store(time, "instructions", cpu, thread, val, ena, run);

def stat__interval(time):
    for cpu in cpus:
        for thread in threads:
            cyc = get(time, "cycles", cpu, thread)
            ins = get(time, "instructions", cpu, thread)
            cpi = 0

            if ins != 0:
                cpi = cyc/float(ins)

            print("%15f: cpu %d, thread %d -> cpi %f (%d/%d)" % (time/(float(1000000000)), cpu, thread, cpi, cyc, ins))

def trace_end():
    pass
# XXX trace_end callback could be used as an alternative place
#     to compute same values as in the script above:
#
#    for time in times:
#        for cpu in cpus:
#            for thread in threads:
#                cyc = get(time, "cycles", cpu, thread)
#                ins = get(time, "instructions", cpu, thread)
#
#                if ins != 0:
#                    cpi = cyc/float(ins)
#
#                print("time %.9f, cpu %d, thread %d -> cpi %f" % (time/(float(1000000000)), cpu, thread, cpi))
linux/commit/net/ipv4/fib_frontend.c?id=a0065f266a9b5d51575535a25c15ccbeed9a9966&follow=1'>fib_frontend: fix possible NULL pointer dereferenceOliver Hartkopp1-0/+2 2014-01-249p: update documentationEric Van Hensbergen1-11/+6 2014-01-24rtnetlink: remove IFLA_BOND_SLAVE definitionJiri Pirko1-1/+0 2014-01-23lib/decompress_unlz4.c: always set an error return code on failuresJan Beulich1-0/+1 2014-01-23romfs: fix returm err while getting inode in fill_superRui Xiang1-4/+2 2014-01-23drivers/w1/masters/w1-gpio.c: add strong pullup emulationEvgeny Boger3-12/+23 2014-01-23drivers/memstick/host/rtsx_pci_ms.c: fix ms card data transfer bugMicky Ching1-10/+20 2014-01-23userns: relax the posix_acl_valid() checksAndreas Gruenbacher1-10/+0 2014-01-23arch/sh/kernel/dwarf.c: use rbtree postorder iteration helper instead of solu...Cody P Schafer1-14/+4 2014-01-23fs-ext3-use-rbtree-postorder-iteration-helper-instead-of-opencoding-fixAndrew Morton1-4/+4 2014-01-23fs/ext3: use rbtree postorder iteration helper instead of opencodingCody P Schafer1-31/+5 2014-01-23fs/jffs2: use rbtree postorder iteration helper instead of opencodingCody P Schafer2-49/+5 2014-01-23fs/ext4: use rbtree postorder iteration helper instead of opencodingCody P Schafer2-59/+9 2014-01-23fs/ubifs: use rbtree postorder iteration helper instead of opencodingCody P Schafer6-114/+17 2014-01-23net/netfilter/ipset/ip_set_hash_netiface.c: use rbtree postorder iteration in...Cody P Schafer1-23/+4 2014-01-23rbtree/test: test rbtree_postorder_for_each_entry_safe()Cody P Schafer1-0/+11 2014-01-23rbtree/test: move rb_node to the middle of the test structCody P Schafer1-1/+1 2014-01-23rapidio: add modular rapidio core build into powerpc and mips branchesAlexandre Bounine2-3/+3 2014-01-23partitions/efi: complete documentation of gpt kernel param purposeDavidlohr Bueso1-1/+3