Skip to content

Commit

Permalink
edit docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrusch committed Feb 18, 2022
1 parent 6c29767 commit 3a331ca
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 90 deletions.
137 changes: 58 additions & 79 deletions c_files/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,90 +4,69 @@

<!--start-->

## Basic Examples

The `basics` folder contains examples of simple C source code performing operations that corresponds to simple derivation trees.

| file | description |
|||
| --- | --- |
`assign_expression.c` | assign result of binary operation to variable
`assign_variable.c` | assign using variable
`if.c` | assignment within conditional statement
`if_else.c` | conditional statement with `if` and `else`
`inline_variable.c` | local variable declaration
`while_1.c` | while loop with assignment
`while_2.c` | while loop with binary operation
`while_if.c` | while loop followed by `if...else`

## Implementation Examples

The `implementation_paper` folder contains examples from "" paper. <!-- TODO: add name and link -->

| file | description |
| **Basics** | Simple C programs performing operations that corresponds to simple derivation trees. |
| `assign_expression.c` | assign result of binary operation to variable
| `assign_variable.c` | assign using variable
| `if.c` | assignment within conditional statement
| `if_else.c` | conditional statement with `if` and `else`
| `inline_variable.c` | local variable declaration
| `while_1.c` | while loop with assignment
| `while_2.c` | while loop with binary operation
| `while_if.c` | while loop followed by `if...else`

|||
| --- | --- |
`example7.c` | An illustration of the sum of two choices.
`example15_a.c` | Examples with function call
`example15_b.c` | Example of an inlined function call
| **Implementation Paper** | Examples from "mwp-Analysis Improvement and Implementation: Realizing Implicit Computational Complexity" paper. |
| `example7.c` | An illustration of the sum of two choices.
| `example15_a.c` | Examples with function call
| `example15_b.c` | Example of an inlined function call


## Infinite Examples

The `infinite` folder contains examples of C source code that are assigned matrices that always contain infinite coefficients, no matter the choices.

| file | description |
|||
| --- | --- |
`exponent_1.c` | exponential computation
`exponent_2.c` | alternative exponential computation
`infinite_2.c` | `while` loop with binary operations, 2 variables
`infinite_3.c` | `while` loop and `if` statement, 3 variables
`infinite_4.c` | `while` loop, 4 variables
`infinite_5.c` | `while` loop and `if` statement, 5 variables
`infinite_6.c` | `if...else` and `while` loop, 6 variables
`infinite_7.c` | 2 `while` loops and `if`, 7 variables
`infinite_8.c` | `while` with nested `if...else` and other conditionals, 8 variables

## Not Infinite Examples

The `not_infinite` folder contains examples of C source code that are assigned matrices that do not always contain infinite coefficients.

| file | description |
| **Infinite** | Programs that are assigned matrices that always contain infinite coefficients, no matter the choices. |
| `exponent_1.c` | exponential computation |
| `exponent_2.c` | alternative exponential computation |
| `infinite_2.c` | `while` loop with binary operations |
| `infinite_3.c` | `while` loop and `if` statement |
| `infinite_4.c` | `while` loop |
| `infinite_5.c` | `while` loop and `if` statement |
| `infinite_6.c` | `if...else` and `while` loop |
| `infinite_7.c` | 2 `while` loops and `if` |
| `infinite_8.c` | `while` with nested `if...else` and other conditionals |

|||
| --- | --- |
`notinfinite_2.c` | binary operations with 2 variables
`notinfinite_3.c` | `if` and `while` loop with 3 variables
`notinfinite_4.c` | `if` and `while` loop with 4 variables
`notinfinite_5.c` | `if` and `while` loop with 5 variables
`notinfinite_6.c` | `if...else` and `while` loop, 6 variables
`notinfinite_7.c` | 2 `while` loops and `if`, 7 variables
`notinfinite_8.c` | `while` with nested `if...else` and other conditionals, 8 variables

## Original Examples

The `original_paper` folder contains examples taken from or inspired from the ["_A Flow Calculus of mwp-Bounds for Complexity Analysis_"](https://doi.org/10.1145/1555746.1555752) paper.

| file | description |
| **Not Infinite** | Programs that are assigned matrices that do not always contain infinite coefficients. |
| `notinfinite_2.c` | binary operations |
| `notinfinite_3.c` | `if` and `while` loop |
| `notinfinite_4.c` | `if` and `while` loop |
| `notinfinite_5.c` | `if` and `while` loop |
| `notinfinite_6.c` | `if...else` and `while` loop |
| `notinfinite_7.c` | 2 `while` loops and `if` |
| `notinfinite_8.c` | `while` with nested `if...else` and other conditionals |

|||
| --- | --- |
`example3_1_a.c` | Analysis of two commands
`example3_1_b.c` | Analysis of two commands
`example3_1_c.c` | Binary operation inside `while` loop
`example3_1_d.c` | Two variables and a `while` loop
`example3_2.c` | Three variables and `while` loop
`example3_4.c` | Iteration with 5 variables
`example5_1.c` | Adding two variables
`example7_10.c` | program with `if...else` and 3 variables
`example7_11.c` | Binary operations with 4 variables


## Other Examples

The `other` folder contains examples of C source code of interest.

| file | description |
| **Original Paper** | Examples taken from or inspired from the ["A Flow Calculus of mwp-Bounds for Complexity Analysis"](https://doi.org/10.1145/1555746.1555752) paper. |
| `example3_1_a.c` | Analysis of two commands
| `example3_1_b.c` | Analysis of two commands
| `example3_1_c.c` | Binary operation inside `while` loop
| `example3_1_d.c` | Two variables and a `while` loop
| `example3_2.c` | Three variables and `while` loop
| `example3_4.c` | Iteration with 5 variables
| `example5_1.c` | Adding two variables
| `example7_10.c` | program with `if...else` and 3 variables
| `example7_11.c` | Binary operations with 4 variables

|||
| --- | --- |
`dense.c` | Produces a 3 x 3 dense matrix.
`dense_loop.c` | Produces a dense matrix with infinite coefficients in it.
`explosion.c` | Explosion of the number of cases
`for_loop.c` | Loop example using `for`
`gcd.c` | Greatest common divisor by subtraction
`simplified_dense.c` | Simplified dense matrix <!-- how is this different? -->

| **Other** | Other programs of interest. |
| `dense.c` | Produces a 3 x 3 dense matrix.
| `dense_loop.c` | Produces a dense matrix with infinite coefficients in it.
| `explosion.c` | Explosion of the number of cases
| `for_loop.c` | Loop example using `for`
| `gcd.c` | Greatest common divisor by subtraction
| `simplified_dense.c` | Simplified dense matrix |
<!--end-->
2 changes: 1 addition & 1 deletion docs/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ table tr th :last-child, table tr td :last-child {
details.quote .highlight pre {
font-size: .75rem;
line-height: 1.8;
}
}
14 changes: 12 additions & 2 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Examples

The project repository [c_files directory](https://github.com/statycc/pymwp/tree/master/c_files) contains
several example programs in C language that can be analyzed using pymwp.
The project repository [c_files](https://github.com/statycc/pymwp/tree/main/c_files)
directory contains example programs in C language that can be analyzed using pymwp.


Also see the [demo](demo.md) which enables running the analysis on these examples online.

<style>
.md-typeset table {border-top:none!important;}
.md-typeset table thead {display:none}
.md-typeset table tr > td:first-child{ min-width:180px }
.md-typeset table tbody > tr:first-child td{ font-size: 110%; background: var(--md-code-bg-color); border-bottom: 0.05rem solid var(--md-typeset-table-color); }
.md-typeset table:not([class]) tbody tr:hover {background-color: transparent}
</style>

{%
include-markdown "../c_files/readme.md"
heading-offset=1
Expand Down
18 changes: 10 additions & 8 deletions docs/utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
## Profiling

Profiling shows how many times different functions are called during analysis. Profiling is carried out using
[cProfile](https://docs.python.org/3/library/profile.html#module-cProfile). You can profile execution of analysis on a single file or multiple files.
[cProfile](https://docs.python.org/3/library/profile.html#module-cProfile). You can profile execution of analysis on
a single file or multiple files.

### Profiling single execution
### Single file

This option can be used with installed package or when running from source.
This option can be used with pymwp installed from package registry or when running from source.

```
python -m cProfile -s ncalls pymwp path/to_some_file.c --silent
Expand All @@ -17,12 +18,13 @@ python -m cProfile -s ncalls pymwp path/to_some_file.c --silent
- use `-s` to specify cProfile output sort order (cf. [options](https://docs.python.org/3/library/profile.html#pstats.Stats.sort_stats))
- use `--silent` to mute analysis output

### Profiling multiple executions
### Multiple files

[Profiler](https://github.com/statycc/pymwp/blob/master/utilities/profiler.py) is a wrapper for cProfile. It enables profiling multiple executions of analysis on a directory of C files (it will recursively search for C files). This utility is not distributed with pymwp package; you must run from source to use it.
Utility module [`profiler.py`](https://github.com/statycc/pymwp/blob/master/utilities/profiler.py) is a wrapper for cProfile.
This utility is not distributed with pymwp package - it must be run from source.


The results of each execution are stored in corresponding files.
It enables profiling multiple executions of analysis on a _directory_ of C files (it recursively searches for
C files). The results of each execution are stored in corresponding files.

1. Run with defaults:

Expand All @@ -46,7 +48,7 @@ The results of each execution are stored in corresponding files.
1 of 3 possible outputs is displayed for each profiled execution:
- done : profiling subprocess terminated without error, note: even if analysis ends with non-0 exit code, it falls into this category if it does not crash the process.
- done-ok : profiling subprocess terminated without error, note: even if analysis ends with non-0 exit code, it falls into this category if it does not crash the process.
- error : profiling subprocess terminated in error.
- timeout : profiling subprocess did not terminate within time limit and was forced to quit.

0 comments on commit 3a331ca

Please sign in to comment.