Module: Rex

Defined in:
lib/rex/core.rb,
lib/rex/file.rb,
lib/rex/compat.rb,
lib/rex/sync/ref.rb,
lib/rex/io/stream.rb,
lib/rex/stopwatch.rb,
lib/rex/exceptions.rb,
lib/rex/sync/event.rb,
lib/rex/core/version.rb,
lib/rex/io/ring_buffer.rb,
lib/rex/io/stream_server.rb,
lib/rex/sync/thread_safe.rb,
lib/rex/sync/read_write_lock.rb,
lib/rex/io/socket_abstraction.rb,
lib/rex/io/stream_abstraction.rb,
lib/rex/io/datagram_abstraction.rb

Defined Under Namespace

Modules: Compat, Core, Exception, FileUtils, Find, HostCommunicationError, IO, Ref, SocketError, Sync, ThreadSafe Classes: AddressInUse, AmbiguousArgumentError, ArgumentError, ArgumentParseError, BindFailed, ConnectionError, ConnectionProxyError, ConnectionRefused, ConnectionTimeout, HostUnreachable, InvalidDestination, NotImplementedError, Quickfile, ReadWriteLock, RuntimeError, StreamClosedError, TimeoutError, UnsupportedProtocol

Class Method Summary collapse

Class Method Details

.stopwatch { ... } ⇒ Object

This provides a correct way to time an operation provided within a block.

Yields:

  • The block whose operation should be timed.

Returns:

  • Returns the result of the block and the elapsed time in seconds.

See Also:



10
11
12
13
14
15
16
# File 'lib/rex/stopwatch.rb', line 10

def self.stopwatch
  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  ret = yield
  elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start

  [ret, elapsed]
end