diff options
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/Documentation/perf-script.txt | 10 | ||||
| -rw-r--r-- | tools/perf/builtin-script.c | 16 |
2 files changed, 17 insertions, 9 deletions
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index 806ec6391fd6..7730c1d2b5d3 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt | |||
| @@ -351,19 +351,19 @@ include::itrace.txt[] | |||
| 351 | to end of file. | 351 | to end of file. |
| 352 | 352 | ||
| 353 | Also support time percent with multipe time range. Time string is | 353 | Also support time percent with multipe time range. Time string is |
| 354 | 'a%/n,b%/m,...' or 'a%-b%,c%-%d,...'. The maximum number of slices is 10. | 354 | 'a%/n,b%/m,...' or 'a%-b%,c%-%d,...'. |
| 355 | 355 | ||
| 356 | For example: | 356 | For example: |
| 357 | Select the second 10% time slice | 357 | Select the second 10% time slice: |
| 358 | perf script --time 10%/2 | 358 | perf script --time 10%/2 |
| 359 | 359 | ||
| 360 | Select from 0% to 10% time slice | 360 | Select from 0% to 10% time slice: |
| 361 | perf script --time 0%-10% | 361 | perf script --time 0%-10% |
| 362 | 362 | ||
| 363 | Select the first and second 10% time slices | 363 | Select the first and second 10% time slices: |
| 364 | perf script --time 10%/1,10%/2 | 364 | perf script --time 10%/1,10%/2 |
| 365 | 365 | ||
| 366 | Select from 0% to 10% and 30% to 40% slices | 366 | Select from 0% to 10% and 30% to 40% slices: |
| 367 | perf script --time 0%-10%,30%-40% | 367 | perf script --time 0%-10%,30%-40% |
| 368 | 368 | ||
| 369 | --max-blocks:: | 369 | --max-blocks:: |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index ac781916e51e..3499d68e1d70 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
| @@ -1480,8 +1480,6 @@ static int perf_sample__fprintf_synth(struct perf_sample *sample, | |||
| 1480 | return 0; | 1480 | return 0; |
| 1481 | } | 1481 | } |
| 1482 | 1482 | ||
| 1483 | #define PTIME_RANGE_MAX 10 | ||
| 1484 | |||
| 1485 | struct perf_script { | 1483 | struct perf_script { |
| 1486 | struct perf_tool tool; | 1484 | struct perf_tool tool; |
| 1487 | struct perf_session *session; | 1485 | struct perf_session *session; |
| @@ -1496,7 +1494,8 @@ struct perf_script { | |||
| 1496 | struct thread_map *threads; | 1494 | struct thread_map *threads; |
| 1497 | int name_width; | 1495 | int name_width; |
| 1498 | const char *time_str; | 1496 | const char *time_str; |
| 1499 | struct perf_time_interval ptime_range[PTIME_RANGE_MAX]; | 1497 | struct perf_time_interval *ptime_range; |
| 1498 | int range_size; | ||
| 1500 | int range_num; | 1499 | int range_num; |
| 1501 | }; | 1500 | }; |
| 1502 | 1501 | ||
| @@ -3445,6 +3444,13 @@ int cmd_script(int argc, const char **argv) | |||
| 3445 | if (err < 0) | 3444 | if (err < 0) |
| 3446 | goto out_delete; | 3445 | goto out_delete; |
| 3447 | 3446 | ||
| 3447 | script.ptime_range = perf_time__range_alloc(script.time_str, | ||
| 3448 | &script.range_size); | ||
| 3449 | if (!script.ptime_range) { | ||
| 3450 | err = -ENOMEM; | ||
| 3451 | goto out_delete; | ||
| 3452 | } | ||
| 3453 | |||
| 3448 | /* needs to be parsed after looking up reference time */ | 3454 | /* needs to be parsed after looking up reference time */ |
| 3449 | if (perf_time__parse_str(script.ptime_range, script.time_str) != 0) { | 3455 | if (perf_time__parse_str(script.ptime_range, script.time_str) != 0) { |
| 3450 | if (session->evlist->first_sample_time == 0 && | 3456 | if (session->evlist->first_sample_time == 0 && |
| @@ -3457,7 +3463,7 @@ int cmd_script(int argc, const char **argv) | |||
| 3457 | } | 3463 | } |
| 3458 | 3464 | ||
| 3459 | script.range_num = perf_time__percent_parse_str( | 3465 | script.range_num = perf_time__percent_parse_str( |
| 3460 | script.ptime_range, PTIME_RANGE_MAX, | 3466 | script.ptime_range, script.range_size, |
| 3461 | script.time_str, | 3467 | script.time_str, |
| 3462 | session->evlist->first_sample_time, | 3468 | session->evlist->first_sample_time, |
| 3463 | session->evlist->last_sample_time); | 3469 | session->evlist->last_sample_time); |
| @@ -3476,6 +3482,8 @@ int cmd_script(int argc, const char **argv) | |||
| 3476 | flush_scripting(); | 3482 | flush_scripting(); |
| 3477 | 3483 | ||
| 3478 | out_delete: | 3484 | out_delete: |
| 3485 | zfree(&script.ptime_range); | ||
| 3486 | |||
| 3479 | perf_evlist__free_stats(session->evlist); | 3487 | perf_evlist__free_stats(session->evlist); |
| 3480 | perf_session__delete(session); | 3488 | perf_session__delete(session); |
| 3481 | 3489 | ||
