Skip to main content
Spec2Vec’s computation time scales with spectrogram image resolution. Understanding this scaling helps you choose the right resolution for your application and set realistic expectations for large-batch processing jobs. The two main metric families — pointwise (statistical, entropy, fractal) and pairwise (spatial zone) — have different scaling behaviors and can be tuned independently.

Benchmarks

The time_complexity_analysis/ directory contains a benchmarking script and pre-computed noise reference banks at three standard resolutions. The table below shows wall-clock times from the pre-computed results file time_complexity_analysis/codes_and_files/time_complexity_results_diff_dims.csv, measured on a single CPU core for batches of 50, 100, 500, and 1000 spectrograms at each resolution.

Timing Results

Raw results are stored in time_complexity_analysis/codes_and_files/time_complexity_results_diff_dims.csv. A visualization of the scaling curves is saved as total_time_complexity_plot_diff_dims.png in the same directory. Key observations:
  • Pointwise metrics dominate at higher resolutions. At 512 × 512, pointwise time is approximately 3× the pairwise time, because entropy and fractal dimension calculations scale with the length of the Hilbert-flattened 1D sequence.
  • Pairwise time grows more slowly with resolution because the histogram alignment and GMM steps operate on a fixed number of bins (hist_bins), not on every pixel directly.
  • Scaling is approximately linear with the number of signals across all resolutions, confirming that the pipeline is embarrassingly parallelizable.
These benchmarks were measured on a single CPU core. If you parallelize across cores using Python’s multiprocessing or joblib, you can expect near-linear speedup up to the number of physical cores available on your machine.

Optimization Strategies

Computing the full feature suite (50+ metrics) is often unnecessary, especially during prototyping. Pass a metrics_list to compute_pointwise_metrics_from_spec() to compute only the features you need.
Computing 4 features instead of 50+ can reduce pointwise runtime by 10–15×, depending on which features you select. Entropy metrics are generally faster than fractal dimension metrics.
Smaller spectrogram images process substantially faster. At 128 × 128, a batch of 1000 signals takes roughly 1069 seconds total; the same batch at 512 × 512 takes over 10 600 seconds — a 10× difference.Choose the smallest resolution that preserves the key frequency content of your signals. For most seismic applications at 100 Hz, a 64 × 64 or 128 × 128 spectrogram captures all diagnostically relevant features. Use the interp_size parameter in compute_imgbank_dict() to standardize images to a target resolution if your raw STFT output is larger.
Always pass your entire signal collection to a single compute_pointwise_metrics_from_spec() call rather than looping over signals and calling the method once per signal. The batch path amortizes Python function-call overhead and enables consistent progress reporting every 50 signals.
For lengthy signals it is best to divide the signals in small chunks (say for e.g. 30 secs) and take the mean, median, max, variance of the metrics across the chunks to represent the whole signal. The small signal lengths will speed up the entire processing and thus can help with processing signals of varying lengths.Refer to optional_esec_spec2vec_rolling_metrics_prep.py file as an example solution.

Running the Benchmark Yourself

To reproduce the timing table above or measure performance on your own hardware, run the benchmarking script from the root of the repository:
The script processes mock signals against the pre-computed noise reference banks stored in time_complexity_analysis/data_noise_ref/: These pre-built banks are provided so that noise-generation overhead does not skew the timing results for the metric extraction steps themselves. Results are written to codes_and_files/time_complexity_results_diff_dims.csv and a summary plot is saved as total_time_complexity_plot_diff_dims.png.
Make sure your Python environment is fully set up with all required dependencies and that you run the script from the root of the repository so that relative imports (SPEC2VEC.utils.*) resolve correctly.