summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/stat-cpi.py
blob: 01fa933ff3cf055d54e76aea1d31cfc730d35ab9 (plain)
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))
:06:11 +0100'>2018-12-13dma-mapping: always build the direct mapping codeChristoph Hellwig 2018-12-10m68k/mac: Switch to use %ptRAndy Shevchenko 2018-12-04m68k: Generate uapi header and syscall table header filesFiroz Khan 2018-12-04m68k: Add system call table generation supportFiroz Khan 2018-12-04m68k: Add __NR_syscalls along with NR_syscallsFiroz Khan 2018-12-03m68k/defconfig: Update defconfigs for v4.20-rc1Geert Uytterhoeven 2018-12-03m68k: Remove redundant 'default n' from KconfigBartlomiej Zolnierkiewicz 2018-12-03m68k: Unroll raw_outsb() loopFinn Thain 2018-11-23pcmcia: allow PCMCIA support independent of the architectureChristoph Hellwig 2018-11-23PCI: consolidate PCI config entry in drivers/pciChristoph Hellwig 2018-11-09Merge tag 's390-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390...Linus Torvalds 2018-11-02mm: make the __PAGETABLE_PxD_FOLDED defines non-emptyMartin Schwidefsky 2018-10-31memblock: stop using implicit alignment to SMP_CACHE_BYTESMike Rapoport 2018-10-31mm: remove include/linux/bootmem.hMike Rapoport 2018-10-31memblock: rename free_all_bootmem to memblock_free_allMike Rapoport 2018-10-31memblock: replace alloc_bootmem with memblock_allocMike Rapoport 2018-10-31memblock: replace alloc_bootmem_pages with memblock_allocMike Rapoport 2018-10-31memblock: replace alloc_bootmem_low_pages with memblock_alloc_lowMike Rapoport 2018-10-31mm: remove CONFIG_HAVE_MEMBLOCKMike Rapoport 2018-10-31mm: remove CONFIG_NO_BOOTMEMMike Rapoport 2018-10-31treewide: remove current_text_addrNick Desaulniers 2018-10-29Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg...Linus Torvalds 2018-10-29Merge tag 'm68k-for-v4.20-tag1' of git://git.kernel.org/pub/scm/linux/kernel/...Linus Torvalds 2018-10-26Merge tag 'powerpc-4.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/p...Linus Torvalds 2018-10-25Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert...Linus Torvalds 2018-10-25Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/ke...Linus Torvalds 2018-10-22Merge tag 'dma-mapping-4.20' of git://git.infradead.org/users/hch/dma-mappingLinus Torvalds 2018-10-16ataflop: fold headers into C fileOmar Sandoval 2018-10-16m68k: fix command-line parsing when passed from u-bootAngelo Dureghello