code: def test_cmdline_profiling(
      tmpdir, mem_gb, n_procs, use_resource_monitor
  ):
      """
      Test runtime profiler correctly records workflow RAM/CPUs consumption
      of a CommandLine-derived interface
      """
      from nipype import config
  
      config.set(
          "monitoring", "sample_frequency", "0.2"
      )  # Force sampling fast
  
      tmpdir.chdir()
      iface = UseResources(mem_gb=mem_gb, n_procs=n_procs)
      result = iface.run()
  
      assert (
          abs(mem_gb - result.runtime.mem_peak_gb) < 0.3
      ), "estimated memory error above .3GB"
      assert (
          int(result.runtime.cpu_percent / 100 + 0.2) == n_procs
      ), "wrong number of threads estimated"
  
file_path: nipype/nipype/interfaces/base/tests/test_resource_monitor.py
imports: import os
  import pytest
  from ....None import config
  from ....utils.profiler import _use_resources
  from ...base import traits, CommandLine, CommandLineInputSpec
  from ...None import utility
label_desc: Use image node_id 2 for calling a global function with example usage: test_cmdline_profiling(tmpdir, mem_gb, n_procs, use_resource_monitor) without return types