diff options
Diffstat (limited to 'tools/perf/scripts/python/export-to-postgresql.py')
-rw-r--r-- | tools/perf/scripts/python/export-to-postgresql.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py index 4cdafd880074..84a32037a80f 100644 --- a/tools/perf/scripts/python/export-to-postgresql.py +++ b/tools/perf/scripts/python/export-to-postgresql.py | |||
@@ -15,6 +15,53 @@ import sys | |||
15 | import struct | 15 | import struct |
16 | import datetime | 16 | import datetime |
17 | 17 | ||
18 | # To use this script you will need to have installed package python-pyside which | ||
19 | # provides LGPL-licensed Python bindings for Qt. You will also need the package | ||
20 | # libqt4-sql-psql for Qt postgresql support. | ||
21 | # | ||
22 | # The script assumes postgresql is running on the local machine and that the | ||
23 | # user has postgresql permissions to create databases. Examples of installing | ||
24 | # postgresql and adding such a user are: | ||
25 | # | ||
26 | # fedora: | ||
27 | # | ||
28 | # $ sudo yum install postgresql postgresql-server python-pyside qt-postgresql | ||
29 | # $ sudo su - postgres -c initdb | ||
30 | # $ sudo service postgresql start | ||
31 | # $ sudo su - postgres | ||
32 | # $ createuser <your user id here> | ||
33 | # Shall the new role be a superuser? (y/n) y | ||
34 | # | ||
35 | # ubuntu: | ||
36 | # | ||
37 | # $ sudo apt-get install postgresql | ||
38 | # $ sudo su - postgres | ||
39 | # $ createuser <your user id here> | ||
40 | # Shall the new role be a superuser? (y/n) y | ||
41 | # | ||
42 | # An example of using this script with Intel PT: | ||
43 | # | ||
44 | # $ perf record -e intel_pt//u ls | ||
45 | # $ perf script -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py pt_example branches calls | ||
46 | # 2015-05-29 12:49:23.464364 Creating database... | ||
47 | # 2015-05-29 12:49:26.281717 Writing to intermediate files... | ||
48 | # 2015-05-29 12:49:27.190383 Copying to database... | ||
49 | # 2015-05-29 12:49:28.140451 Removing intermediate files... | ||
50 | # 2015-05-29 12:49:28.147451 Adding primary keys | ||
51 | # 2015-05-29 12:49:28.655683 Adding foreign keys | ||
52 | # 2015-05-29 12:49:29.365350 Done | ||
53 | # | ||
54 | # To browse the database, psql can be used e.g. | ||
55 | # | ||
56 | # $ psql pt_example | ||
57 | # pt_example=# select * from samples_view where id < 100; | ||
58 | # pt_example=# \d+ | ||
59 | # pt_example=# \d+ samples_view | ||
60 | # pt_example=# \q | ||
61 | # | ||
62 | # An example of using the database is provided by the script | ||
63 | # call-graph-from-postgresql.py. Refer to that script for details. | ||
64 | |||
18 | from PySide.QtSql import * | 65 | from PySide.QtSql import * |
19 | 66 | ||
20 | # Need to access PostgreSQL C library directly to use COPY FROM STDIN | 67 | # Need to access PostgreSQL C library directly to use COPY FROM STDIN |