Skip to content

Commit bb80635

Browse files
committed
Python: CG trace: Updated README
1 parent ecafc76 commit bb80635

File tree

1 file changed

+29
-6
lines changed
  • python/tools/recorded-call-graph-metrics

1 file changed

+29
-6
lines changed

python/tools/recorded-call-graph-metrics/README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,28 @@ also known as _call graph tracing_.
44

55
Execute a python program and for each call being made, record the call and callee. This allows us to compare call graph resolution from static analysis with actual data -- that is, can we statically determine the target of each actual call correctly.
66

7-
## How do I give it a spin?
7+
Using the call graph tracer does incur heave toll on the performance. Expect 10x longer to execute program.
88

9-
After following setup instructions below, you should be able to reproduce the example trace by running
9+
Number of calls recorded vary a little from run to run. I have not been able to pinpoint why.
1010

11-
```
12-
cg-trace --xml example/simple.xml example/simple.py
11+
## Running against real projects
12+
13+
Currently it's possible to gather metrics from traced runs against two projects (defined in [projects.json](./projects.json)): `youtube-dl` and `wcwidth`.
14+
15+
To run against all projects, use
16+
17+
```bash
18+
$ ./helper.sh all $(./helper.sh projects)
1319
```
1420

15-
You can also run traces for all tests and build a database by running `tests/create-test-db.sh`. Then run the queries inside the `ql/` directory.
21+
To view the results, use
22+
```
23+
$ head -n 100 projects/*/Metrics.txt
24+
```
1625

26+
## Local development
1727

18-
## Setup
28+
### Setup
1929

2030
1. Ensure you have at least Python 3.7
2131

@@ -47,9 +57,22 @@ You can also run traces for all tests and build a database by running `tests/cre
4757

4858
6. Enjoy writing code, and being able to run `cg-trace` on your command line :tada:
4959

60+
### Using it
61+
62+
After following setup instructions above, you should be able to reproduce the example trace by running
63+
64+
```
65+
cg-trace --xml example/simple.xml example/simple.py
66+
```
67+
68+
You can also run traces for all tests and build a database by running `tests/create-test-db.sh`. Then run the queries inside the `ql/` directory.
5069

5170
## Tracing Limitations
5271

72+
### Multi-threading
73+
74+
Should be possible by using [`threading.setprofile`](https://docs.python.org/3.8/library/threading.html#threading.setprofile), but that hasn't been done yet.
75+
5376
### Code that uses `sys.setprofile`
5477

5578
Since that is our mechanism for recording calls, any code that uses `sys.setprofile` will not work together with the call-graph tracer.

0 commit comments

Comments
 (0)