Frequently Asked Questions

  • How to define the logger for python-signal-edges?

    get_logger()

    Retrieves the logger for the package, this logger can be configured externally like below:

    logger = logging.getLogger("python-signal-edges-logger")
    
    # Configure logger...
    
    # Mark as initialized.
    setattr(logger, "init", True)
    

    If the logger is not configured externally, the library uses a no-op logger by default. This logger can be used by both the package and the user, and it is available in all the base classes in this package for their derived classes to use.

    Return type:

    Logger

    Returns:

    The logger.

  • What benchmarking capabilities exist in python-signal-edges?

    The files at tests/benchmark provide an example script to do profiling that can be customized for different scenarios, it relies on line_profiler package.

    The code snippet below shows how to run the benchmark script from a PowerShell terminal and save the results to file:

    kernprof --line-by-line --builtin --outfile './tests/benchmark/benchmark.lprof' './tests/benchmark/benchmark.py';
    $output = python -m line_profiler -rmt "./tests/benchmark/benchmark.lprof";
    $output = $output -join [System.Environment]::NewLine;
    Set-Content -Path "./tests/benchmark/benchmark.txt" -Value "$output" -Force;
    

    The following shows benchmarks for signals of different types using these scripts:

    ~100k samples with ~500 edges:
        Filtering: 0.00 seconds, State Levels: 0.01 seconds, Edges: 0.06 seconds
    ~100k samples with ~5k edges:
        Filtering: 0.00 seconds, State Levels: 0.01 seconds, Edges: 0.61 seconds
    ~1M samples with ~5k edges:
        Filtering: 0.03 seconds, State Levels: 0.03 seconds, Edges: 0.58 seconds
    ~1M samples with ~50k edges:
        Filtering: 0.02 seconds, State Levels: 0.03 seconds, Edges: 4.86 seconds
    ~10M samples with ~50k edges:
        Filtering: 0.23 seconds, State Levels: 0.25 seconds, Edges: 5.32 seconds
    ~10M samples with ~500k edges:
        Filtering: 0.24 seconds, State Levels: 0.31 seconds, Edges: 52.75 seconds
    ~30M samples with ~25k edges:
        Filtering: 0.68 seconds, State Levels: 1.83 seconds, Edges: 4.50 seconds
    ~30M samples with ~2k edges:
        Filtering: 0.08 seconds, State Levels: 0.52 seconds, Edges: 0.88 seconds
    ~30M samples with ~150k edges:
        Filtering: 0.66 seconds, State Levels: 0.87 seconds, Edges: 19.44 seconds
    

    Below some notes are listed in terms of performance:

    • If the full range of the signal calculated from the state levels, StateLevels, is below an expected value for the user system, then a processing to extract edges can be skipped as there isn’t any.

    • Runt edges, Type are more time consuming to extract than normal edges, a signal with an excessive amount of runt edges can be a symptom of issues in the system or in the acquisition and a better signal conditioning could reduce their number.

    • The intermediate point policy for edges, IntPointPolicy, can be adjusted to avoid calculation of intermediate points, forcing the use of the begin or end values as intermediate. This can be convenient when the rising or falling times of the system are fast for the acquisition system to acquire samples during that period.

    • For specific scenarios, disabling logging and the garbage collector temporarily during the processing.