code: def ringtest(comm, args=None, verbose=True):
      """Time a message going around the ring of processes."""
      # pylint: disable=too-many-locals
      # pylint: disable=too-many-statements
      # pylint: disable=import-outside-toplevel
      from argparse import ArgumentParser
  
      parser = ArgumentParser(prog=_prog("ringtest"))
      parser.add_argument(
          "-q",
          "--quiet",
          action="store_false",
          dest="verbose",
          default=verbose,
          help="quiet output",
      )
      parser.add_argument(
          "-n",
          "--size",
          type=int,
          dest="size",
          default=1,
          help="message size",
      )
      parser.add_argument(
          "-s",
          "--skip",
          type=int,
          dest="skip",
          default=0,
          help="number of warm-up iterations",
      )
      parser.add_argument(
          "-l",
          "--loop",
          type=int,
          dest="loop",
          default=1,
          help="number of iterations",
      )
      options = parser.parse_args(args)
  
      def ring(comm, n=1, loop=1, skip=0):
          # pylint: disable=invalid-name
          from array import array
          from . import MPI
  
          iterations = list(range(loop + skip))
          size = comm.Get_size()
          rank = comm.Get_rank()
          source = (rank - 1) % size
          dest = (rank + 1) % size
          Sendrecv = comm.Sendrecv
          Send = comm.Send
          Recv = comm.Recv
          Wtime = MPI.Wtime
          sendmsg = array("B", [+42]) * n
          recvmsg = array("B", [0x0]) * n
          if size == 1:
              for i in iterations:
                  if i == skip:
                      tic = Wtime()
                  Sendrecv(sendmsg, dest, 0, recvmsg, source, 0)
          else:
              if rank == 0:
                  for i in iterations:
                      if i == skip:
                          tic = Wtime()
                      Send(sendmsg, dest, 0)
                      Recv(recvmsg, source, 0)
              else:
                  sendmsg = recvmsg
                  for i in iterations:
                      if i == skip:
                          tic = Wtime()
                      Recv(recvmsg, source, 0)
                      Send(sendmsg, dest, 0)
          toc = Wtime()
          if comm.rank == 0 and sendmsg != recvmsg:  # pragma: no cover
              from warnings import warn
              import traceback
  
              try:
                  warn("received message does not match!", stacklevel=1)
              except UserWarning:
                  traceback.print_exc()
                  comm.Abort(2)
          return toc - tic
  
      size = getattr(options, "size", 1)
      loop = getattr(options, "loop", 1)
      skip = getattr(options, "skip", 0)
      comm.Barrier()
      elapsed = ring(comm, size, loop, skip)
      if options.verbose and comm.rank == 0:
          _sys.stdout.write(
              f"time for {loop} loops = {elapsed:g} seconds "
              f"({comm.size} processes, {size} bytes)\n"
          )
          _sys.stdout.flush()
      return elapsed
  
file_path: mpi4py/src/mpi4py/bench.py
imports: import os
  import sys
label_desc: Use image node_id 3 for calling a global function with example usage: ringtest(comm, args, verbose) and returns: elapsed, unknown