result.py¶
from pymwp import Result
FuncResult
¶
Bases: Timeable
Capture details of analysis result for one program (function in C).
Source code in pymwp/result.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
n_bounds: int
property
¶
Number of bounds.
n_vars: int
property
¶
Number of variables.
__init__(name, infinite=False, variables=None, relation=None, choices=None, bound=None)
¶
Create a function result.
Attributes:
Name | Type | Description |
---|---|---|
name |
function name |
|
infinite |
True if result is infinite. |
|
variables |
list of variables. |
|
relation |
corresponding |
|
choices |
choice object |
|
bound |
bound object |
Source code in pymwp/result.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
from_dict(**kwargs)
staticmethod
¶
Deserialize function result.
Source code in pymwp/result.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
to_dict()
¶
Serialize function result.
Source code in pymwp/result.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
Program
¶
Bases: object
Details about analyzed C file.
Source code in pymwp/result.py
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 80 81 82 83 84 85 |
|
name: Optional[str]
property
¶
Get name of program, without path and extension.
Returns:
Type | Description |
---|---|
Optional[str]
|
Program name or |
__init__(n_lines=-1, program_path=None)
¶
Create program object.
Attributes:
Name | Type | Description |
---|---|---|
n_lines |
int
|
number of lines. |
program_path |
str
|
path to program file. |
Source code in pymwp/result.py
50 51 52 53 54 55 56 57 58 |
|
from_dict(**kwargs)
staticmethod
¶
Initialize Program object from kwargs.
Returns:
Name | Type | Description |
---|---|---|
Program |
Program
|
initialized program object. |
Raises:
Type | Description |
---|---|
KeyError
|
if all Program attributes are not included as kwargs. |
Source code in pymwp/result.py
75 76 77 78 79 80 81 82 83 84 85 |
|
to_dict()
¶
Convert Program object to a dictionary.
Source code in pymwp/result.py
60 61 62 63 64 |
|
Result
¶
Bases: Timeable
Captures analysis result and details about the process.
This result contains
- program: information about analyzed C File:
type
Program
- relations: dictionary of function results:
type
FuncResult
- analysis time: measured from before any function has been analyzed, until all functions have been analyzed. It excludes time to write result to file.
Source code in pymwp/result.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
n_functions: int
property
¶
Number of functions in analyzed program.
add_relation(func_result)
¶
Appends function analysis outcome to result.
Attributes:
Name | Type | Description |
---|---|---|
func_result |
function analysis to append to Result. |
Source code in pymwp/result.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
deserialize(**kwargs)
staticmethod
¶
Reverse of serialize.
Returns:
Name | Type | Description |
---|---|---|
Result |
Result
|
Initialized Result object. |
Source code in pymwp/result.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
get_func(name=None)
¶
Returns analysis result for function(s).
- If
name
argument is provided and key exists, returns function result for exact value match. - If program contained exactly 1 function, returns result for that function.
- Otherwise, returns a dictionary of results for each
analyzed function, as in:
<function_name, analysis_result>
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Optional[str]
|
name of function |
None
|
Returns:
Type | Description |
---|---|
Union[FuncResult, Dict[str, FuncResult]]
|
Function analysis result, or dictionary of results. |
Source code in pymwp/result.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
log_result()
¶
Display here all interesting stats.
Source code in pymwp/result.py
229 230 231 232 233 234 235 236 |
|
serialize()
¶
JSON serialize a result object.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
dictionary representation. |
Source code in pymwp/result.py
238 239 240 241 242 243 244 245 246 247 248 |
|
Timeable
¶
Represents an entity whose runtime can be measured.
Source code in pymwp/result.py
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 |
|
dur_ms: int
property
¶
Duration in milliseconds.
dur_s: float
property
¶
Duration in seconds.
time_diff: int
property
¶
Time delta between analysis start and end time.
on_end()
¶
Called at end of timeable entity.
Source code in pymwp/result.py
41 42 43 44 |
|
on_start()
¶
Called at start of timeable entity.
Source code in pymwp/result.py
36 37 38 39 |
|