diff options
Diffstat (limited to 'tools/perf/scripts/python/export-to-postgresql.py')
-rw-r--r-- | tools/perf/scripts/python/export-to-postgresql.py | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py index b2f481b0d28d..93225c02117e 100644 --- a/tools/perf/scripts/python/export-to-postgresql.py +++ b/tools/perf/scripts/python/export-to-postgresql.py | |||
@@ -394,7 +394,9 @@ if branches: | |||
394 | 'to_ip bigint,' | 394 | 'to_ip bigint,' |
395 | 'branch_type integer,' | 395 | 'branch_type integer,' |
396 | 'in_tx boolean,' | 396 | 'in_tx boolean,' |
397 | 'call_path_id bigint)') | 397 | 'call_path_id bigint,' |
398 | 'insn_count bigint,' | ||
399 | 'cyc_count bigint)') | ||
398 | else: | 400 | else: |
399 | do_query(query, 'CREATE TABLE samples (' | 401 | do_query(query, 'CREATE TABLE samples (' |
400 | 'id bigint NOT NULL,' | 402 | 'id bigint NOT NULL,' |
@@ -418,7 +420,9 @@ else: | |||
418 | 'data_src bigint,' | 420 | 'data_src bigint,' |
419 | 'branch_type integer,' | 421 | 'branch_type integer,' |
420 | 'in_tx boolean,' | 422 | 'in_tx boolean,' |
421 | 'call_path_id bigint)') | 423 | 'call_path_id bigint,' |
424 | 'insn_count bigint,' | ||
425 | 'cyc_count bigint)') | ||
422 | 426 | ||
423 | if perf_db_export_calls or perf_db_export_callchains: | 427 | if perf_db_export_calls or perf_db_export_callchains: |
424 | do_query(query, 'CREATE TABLE call_paths (' | 428 | do_query(query, 'CREATE TABLE call_paths (' |
@@ -439,7 +443,9 @@ if perf_db_export_calls: | |||
439 | 'return_id bigint,' | 443 | 'return_id bigint,' |
440 | 'parent_call_path_id bigint,' | 444 | 'parent_call_path_id bigint,' |
441 | 'flags integer,' | 445 | 'flags integer,' |
442 | 'parent_id bigint)') | 446 | 'parent_id bigint,' |
447 | 'insn_count bigint,' | ||
448 | 'cyc_count bigint)') | ||
443 | 449 | ||
444 | do_query(query, 'CREATE VIEW machines_view AS ' | 450 | do_query(query, 'CREATE VIEW machines_view AS ' |
445 | 'SELECT ' | 451 | 'SELECT ' |
@@ -521,6 +527,9 @@ if perf_db_export_calls: | |||
521 | 'return_time,' | 527 | 'return_time,' |
522 | 'return_time - call_time AS elapsed_time,' | 528 | 'return_time - call_time AS elapsed_time,' |
523 | 'branch_count,' | 529 | 'branch_count,' |
530 | 'insn_count,' | ||
531 | 'cyc_count,' | ||
532 | 'CASE WHEN cyc_count=0 THEN CAST(0 AS NUMERIC(20, 2)) ELSE CAST((CAST(insn_count AS FLOAT) / cyc_count) AS NUMERIC(20, 2)) END AS IPC,' | ||
524 | 'call_id,' | 533 | 'call_id,' |
525 | 'return_id,' | 534 | 'return_id,' |
526 | 'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE CAST ( flags AS VARCHAR(6) ) END AS flags,' | 535 | 'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE CAST ( flags AS VARCHAR(6) ) END AS flags,' |
@@ -546,7 +555,10 @@ do_query(query, 'CREATE VIEW samples_view AS ' | |||
546 | 'to_sym_offset,' | 555 | 'to_sym_offset,' |
547 | '(SELECT short_name FROM dsos WHERE id = to_dso_id) AS to_dso_short_name,' | 556 | '(SELECT short_name FROM dsos WHERE id = to_dso_id) AS to_dso_short_name,' |
548 | '(SELECT name FROM branch_types WHERE id = branch_type) AS branch_type_name,' | 557 | '(SELECT name FROM branch_types WHERE id = branch_type) AS branch_type_name,' |
549 | 'in_tx' | 558 | 'in_tx,' |
559 | 'insn_count,' | ||
560 | 'cyc_count,' | ||
561 | 'CASE WHEN cyc_count=0 THEN CAST(0 AS NUMERIC(20, 2)) ELSE CAST((CAST(insn_count AS FLOAT) / cyc_count) AS NUMERIC(20, 2)) END AS IPC' | ||
550 | ' FROM samples') | 562 | ' FROM samples') |
551 | 563 | ||
552 | 564 | ||
@@ -618,10 +630,10 @@ def trace_begin(): | |||
618 | comm_table(0, "unknown") | 630 | comm_table(0, "unknown") |
619 | dso_table(0, 0, "unknown", "unknown", "") | 631 | dso_table(0, 0, "unknown", "unknown", "") |
620 | symbol_table(0, 0, 0, 0, 0, "unknown") | 632 | symbol_table(0, 0, 0, 0, 0, "unknown") |
621 | sample_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | 633 | sample_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) |
622 | if perf_db_export_calls or perf_db_export_callchains: | 634 | if perf_db_export_calls or perf_db_export_callchains: |
623 | call_path_table(0, 0, 0, 0) | 635 | call_path_table(0, 0, 0, 0) |
624 | call_return_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | 636 | call_return_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) |
625 | 637 | ||
626 | unhandled_count = 0 | 638 | unhandled_count = 0 |
627 | 639 | ||
@@ -772,11 +784,11 @@ def branch_type_table(branch_type, name, *x): | |||
772 | value = struct.pack(fmt, 2, 4, branch_type, n, name) | 784 | value = struct.pack(fmt, 2, 4, branch_type, n, name) |
773 | branch_type_file.write(value) | 785 | branch_type_file.write(value) |
774 | 786 | ||
775 | def sample_table(sample_id, evsel_id, machine_id, thread_id, comm_id, dso_id, symbol_id, sym_offset, ip, time, cpu, to_dso_id, to_symbol_id, to_sym_offset, to_ip, period, weight, transaction, data_src, branch_type, in_tx, call_path_id, *x): | 787 | def sample_table(sample_id, evsel_id, machine_id, thread_id, comm_id, dso_id, symbol_id, sym_offset, ip, time, cpu, to_dso_id, to_symbol_id, to_sym_offset, to_ip, period, weight, transaction, data_src, branch_type, in_tx, call_path_id, insn_cnt, cyc_cnt, *x): |
776 | if branches: | 788 | if branches: |
777 | value = struct.pack("!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiiiBiq", 18, 8, sample_id, 8, evsel_id, 8, machine_id, 8, thread_id, 8, comm_id, 8, dso_id, 8, symbol_id, 8, sym_offset, 8, ip, 8, time, 4, cpu, 8, to_dso_id, 8, to_symbol_id, 8, to_sym_offset, 8, to_ip, 4, branch_type, 1, in_tx, 8, call_path_id) | 789 | value = struct.pack("!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiiiBiqiqiq", 20, 8, sample_id, 8, evsel_id, 8, machine_id, 8, thread_id, 8, comm_id, 8, dso_id, 8, symbol_id, 8, sym_offset, 8, ip, 8, time, 4, cpu, 8, to_dso_id, 8, to_symbol_id, 8, to_sym_offset, 8, to_ip, 4, branch_type, 1, in_tx, 8, call_path_id, 8, insn_cnt, 8, cyc_cnt) |
778 | else: | 790 | else: |
779 | value = struct.pack("!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiqiqiqiqiiiBiq", 22, 8, sample_id, 8, evsel_id, 8, machine_id, 8, thread_id, 8, comm_id, 8, dso_id, 8, symbol_id, 8, sym_offset, 8, ip, 8, time, 4, cpu, 8, to_dso_id, 8, to_symbol_id, 8, to_sym_offset, 8, to_ip, 8, period, 8, weight, 8, transaction, 8, data_src, 4, branch_type, 1, in_tx, 8, call_path_id) | 791 | value = struct.pack("!hiqiqiqiqiqiqiqiqiqiqiiiqiqiqiqiqiqiqiqiiiBiqiqiq", 24, 8, sample_id, 8, evsel_id, 8, machine_id, 8, thread_id, 8, comm_id, 8, dso_id, 8, symbol_id, 8, sym_offset, 8, ip, 8, time, 4, cpu, 8, to_dso_id, 8, to_symbol_id, 8, to_sym_offset, 8, to_ip, 8, period, 8, weight, 8, transaction, 8, data_src, 4, branch_type, 1, in_tx, 8, call_path_id, 8, insn_cnt, 8, cyc_cnt) |
780 | sample_file.write(value) | 792 | sample_file.write(value) |
781 | 793 | ||
782 | def call_path_table(cp_id, parent_id, symbol_id, ip, *x): | 794 | def call_path_table(cp_id, parent_id, symbol_id, ip, *x): |
@@ -784,7 +796,7 @@ def call_path_table(cp_id, parent_id, symbol_id, ip, *x): | |||
784 | value = struct.pack(fmt, 4, 8, cp_id, 8, parent_id, 8, symbol_id, 8, ip) | 796 | value = struct.pack(fmt, 4, 8, cp_id, 8, parent_id, 8, symbol_id, 8, ip) |
785 | call_path_file.write(value) | 797 | call_path_file.write(value) |
786 | 798 | ||
787 | def call_return_table(cr_id, thread_id, comm_id, call_path_id, call_time, return_time, branch_count, call_id, return_id, parent_call_path_id, flags, parent_id, *x): | 799 | def call_return_table(cr_id, thread_id, comm_id, call_path_id, call_time, return_time, branch_count, call_id, return_id, parent_call_path_id, flags, parent_id, insn_cnt, cyc_cnt, *x): |
788 | fmt = "!hiqiqiqiqiqiqiqiqiqiqiiiq" | 800 | fmt = "!hiqiqiqiqiqiqiqiqiqiqiiiqiqiq" |
789 | value = struct.pack(fmt, 12, 8, cr_id, 8, thread_id, 8, comm_id, 8, call_path_id, 8, call_time, 8, return_time, 8, branch_count, 8, call_id, 8, return_id, 8, parent_call_path_id, 4, flags, 8, parent_id) | 801 | value = struct.pack(fmt, 14, 8, cr_id, 8, thread_id, 8, comm_id, 8, call_path_id, 8, call_time, 8, return_time, 8, branch_count, 8, call_id, 8, return_id, 8, parent_call_path_id, 4, flags, 8, parent_id, 8, insn_cnt, 8, cyc_cnt) |
790 | call_file.write(value) | 802 | call_file.write(value) |