Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Conversation

nader-zouaoui
Copy link
Contributor

@nader-zouaoui nader-zouaoui commented Nov 28, 2024

Description

In this PR we added 2 new classes to the project that help with parsing command line before doing any logic in the app:

  • arg_parser_arg struc an abstract struct that represents a command line argument and defines how it should be parsed
    • arg_parser_arg_opt inherits from arg_parser_arg and defines an optional argument that takes no addition parameter
    • arg_parser_arg_pos inherits from arg_parser_arg and defines a positional argument that takes one or more parameter
      • Note: -1 number of parameters implies that it can take as many parameter as you give it ( useful for -- extra arg or the man command if query becomes more complex in the future )
  • arg_parser under the ArgParser namespace
    • in the header file of this class we define all the possible parameters that the app needs with their description
    • the arg_parser exposes 2 main functions
      void arg_parser::parse(const int argc, const wchar_t* argv[])) and void arg_parser::print_help()
  • parse is expected to throw if parsing does not go as expected

Related Issue

Related to #33
fixes #35

Commits

${{ github.event.pull_request.commits }}

How Has This Been Tested?

image

@PrzemekWirkus PrzemekWirkus marked this pull request as draft November 28, 2024 16:29
@PrzemekWirkus PrzemekWirkus added the enhancement New feature or request label Nov 28, 2024
@PrzemekWirkus PrzemekWirkus added this to the v4.0.0 milestone Nov 28, 2024
@PrzemekWirkus
Copy link
Collaborator

This needs some updates to build properly.

@PrzemekWirkus PrzemekWirkus self-assigned this Nov 28, 2024
@nader-zouaoui
Copy link
Contributor Author

New test results
image

@nader-zouaoui nader-zouaoui marked this pull request as ready for review November 29, 2024 10:41
@nader-zouaoui
Copy link
Contributor Author

new help output

NAME:
        wperf - Performance analysis tools for Windows on Arm

        Usage: wperf <command> [options]

SYNOPSIS:

        -h, --help
           wperf help
           Run wperf help command.

        --version
           wperf --version
           Display version.

        sample
           wperf sample [-e] [--timeout] [-c] [-C] [-E] [-q] [--json] [--output] [--config]
           [--image_name] [--pe_file] [--pdb_file] [--sample-display-long] [--force-lock]
           [--sample-display-row] [--symbol] [--record_spawn_delay] [--annotate]
           [--disassemble]
           Sampling mode, for determining the frequencies of event occurrences produced by
           program locations at the function, basic block, and/or instruction levels.

        stat
           wperf stat [-e] [-m] [-t] [-i] [-n] [-c] [-C] [-E] [-k] [--dmc] [-q] [--json]
           [--output][--config] [--force-lock] --COMMAND [ARGS]
           Counting mode, for obtaining aggregate counts of occurrences of special events.

        record
           wperf record [-e] [--timeout] [-c] [-C] [-E] [-q] [--json] [--output] [--config]
           [--image_name] [--pe_file] [--pdb_file] [--sample-display-long] [--force-lock]
           [--sample-display-row] [--symbol] [--record_spawn_delay] [--annotate]
           [--disassemble] --COMMAND[ARGS]
           Same as sample but also automatically spawns the process and pins it to the core
           specified by `-c`. Process name is defined by COMMAND. User can pass verbatim
           arguments to the process with[ARGS].

        list, -l
           wperf list [-v] [--json] [--force-lock]
           List supported events and metrics. Enable verbose mode for more details.

        test
           wperf test [--json] [OPTIONS]
           Configuration information about driver and application.

        detect
           wperf detect [--json] [OPTIONS]
           List installed WindowsPerf-like Kernel Drivers (match GUID).

        man
           wperf man [--json]
           Plain text information about one or more specified event(s), metric(s), and or
           group metric(s).

OPTIONS:

        --json
           Define output type as JSON.

        -m
           Specify comma separated list of metrics to count.
           Note: see list of available metric names using `list` command.

        -e
           Specify comma separated list of event names (or raw events) to count, for example
           `ld_spec,vfp_spec,r10`. Use curly braces to group events.
           Specify comma separated list of event names with sampling frequency to sample,
           for example `ld_spec:100000`.
           Raw events: specify raw evens with `r<VALUE>` where `<VALUE>` is a 16-bit
           hexadecimal event index value without leading `0x`. For example `r10` is event
           with index `0x10`.
           Note: see list of available event names using `list` command.

        -k
           Count kernel mode as well (disabled by default).

        --force-lock
           Force driver to give lock to current `wperf` process, use when you want to
           interrupt currently executing `wperf` session or to recover from the lock.

        --sample-display-long
           Display decorated symbol names.

        --verbose, -v
           Enable verbose output also in JSON output.

        -q
           Quiet mode, no output is produced.

        --annotate
           Enable translating addresses taken from samples in sample/record mode into source
           code line numbers.

        --disassemble
           Enable disassemble output on sampling mode. Implies 'annotate'.

        -t
           Enable timeline mode (count multiple times with specified interval). Use `-i` to
           specify timeline interval, and `-n` to specify number of counts.

        -c, --cores
           Specify comma separated list of CPU cores, and or ranges of CPU cores, to count
           on, or one CPU to sample on.

        --timeout, sleep
           Specify counting or sampling duration. If not specified, press Ctrl+C to
           interrupt counting or sampling. Input may be suffixed by one (or none) of the
           following units, with up to 2 decimal points: "ms", "s", "m", "h", "d" (i.e.
           milliseconds, seconds, minutes, hours, days). If no unit is provided, the default
           unit is seconds. Accuracy is 0.1 sec.

        --symbol, -s
           Filter results for specific symbols (for use with 'record' and 'sample'
           commands).

        --record_spawn_delay
           Set the waiting time, in milliseconds, before reading process data after spawning
           it with `record`.

        --sample-display-row
           Set how many samples you want to see in the summary (50 by default).

        --pe_file
           Specify the PE filename (and path).

        --image_name
           Specify the image name you want to sample.

        --pdb_file
           Specify the PDB filename (and path), PDB file should directly corresponds to a PE
           file set with `--pe_file`.

        -C
           Provide customized config file which describes metrics.

        -E
           Provide customized config file which describes custom events or provide custom
           events from the command line.

        --output, -o
           Specify JSON output filename.

        --output-csv
           Specify CSV output filename. Only with timeline `-t`.

        --output-prefix, --cwd
           Set current working dir for storing output JSON and CSV file.

        --config
           Specify configuration parameters.

        -i
           Specify counting interval. `0` seconds is allowed. Input may be suffixed with
           one(or none) of the following units, with up to 2 decimal points : "ms", "s",
           "m", "h", "d" (i.e.milliseconds, seconds, minutes, hours, days).If no unit is
           provided, the default unit is seconds(60s by default).

        -n
           Number of consecutive counts in timeline mode (disabled by default).

        --dmc
           Profile on the specified DDR controller. Skip `--dmc` to count on all DMCs.

        --export_perf_data
           Generate local `perf.data` file with partial profiling information (experimental
           only).

        --
           Double-dash is a syntax used signify end of command options. It separates `wperf`
           command line options from arguments that the process spawn command operates on.
           Use `--` to separate `wperf.exe` command line options from the process you want
           to spawn followed by its verbatim arguments.

EXAMPLES:

        > wperf sample -e ld_spec:100000 --pe_file python_d.exe -c 1
        Sample event `ld_spec` with frequency `100000` already running process
        `python_d.exe` on core #1. Press Ctrl + C to stop sampling and see the results.

        > wperf stat -e inst_spec,vfp_spec,ase_spec,ld_spec -c 0 --timeout 3
        Count events `inst_spec`, `vfp_spec`, `ase_spec` and `ld_spec` on core #0 for 3
        seconds.

        > wperf stat -m imix -e l1i_cache -c 7 --timeout 10.5
        Count metric `imix` (metric events will be grouped) and additional event
        `l1i_cache` on core #7 for 10.5 seconds.

        > wperf stat -m imix -c 1 -t -i 2 -n 3 --timeout 5
        Count in timeline mode(output counting to CSV file) metric `imix` 3 times on core
        #1 with 2 second intervals(delays between counts). Each count will last 5
        seconds.

        > wperf record -e ld_spec:100000 -c 1 --timeout 30 -- python_d.exe -c 10**10**100
        Launch `python_d.exe - c 10 * *10 * *100` process and start sampling event
        `ld_spec` with frequency `100000` on core #1 for 30 seconds.
        Hint: add `--annotate` or `--disassemble` to `wperf record` command line
        parameters to increase sampling "resolution".

        > wperf list -v
        List all events and metrics available on your host with extended information.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor out pmu_device functionality out of user-request
2 participants