Skip to main content

Similar to the Linux time utility for timing commands. Useful under Windows.

Project description

Build Status

cmdtime

  • Similar to the Linux time utility for measuring how long a command takes to run
  • Useful for the Windows Command Prompt
  • Uses pure Python
  • No point using this under Linux
  • No need to install Cygwin

Installation

  • Requires Python 3.5+.
  • Install from PyPi:
python -m pip install cmdtime

Usage Examples

  • Time a Python script
cmdtime python whateverscript.py
  • Time anything else
cmdtime dir

Notes

For some machine learning projects, I use the Windows command prompt to execute scripts. I use Windows so that Tensorflow can access my PC's NVIDIA GPU. (Unfortunately, using Linux under VirtualBox can't access GPUs.)

In addition, there is no built-in equivalent of the Linux time utility in the Windows 10 command prompt. Yes, there are other options such as those discussed here and here. But they either require installing old binaries that I'd rather avoid, or involve more cumbersome approaches. I wanted something where I can just prefix the command I want to run similar to the Linux time utility.

Hence the creation of this really trivial but useful Linux time-like utility which I'm calling cmdtime. And it's pure Python.

Probably someone else has already created such a utility under PyPi, but I couldn't find it.

Developer Notes

python setup.py sdist
python -m pip install --editable .
  • Push to TestPyPI
python -m twine upload --repository testpypi dist/*
  • Push to PyPI
python -m twine upload dist/*

Testing Notes

Tests are written to support both Windows and Linux, although this utility is not really needed in Linux.

  • Install pytest:
python -m pip install --upgrade pytest
  • Local testing:
pytest -v
  • Travis CI:
    • Right now, Travis CI doesn't support Python on Windows, so this can only be tested on Linux.
    • The tests only work on Python 3.7 or later as the subprocess.run() had significant changes in parameters (capture_output, text) not available in earlier versions. While it's possible to create version-specific test code to be compatible with earlier versions, it's not worth the effort...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmdtime-0.0.4.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file cmdtime-0.0.4.tar.gz.

File metadata

  • Download URL: cmdtime-0.0.4.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for cmdtime-0.0.4.tar.gz
Algorithm Hash digest
SHA256 dc6ac174f7b4ce0ed49ba1470cd512ba3042ab5152acbaa1aa8e5f2e21cad93a
MD5 3f8cee0c5b9255d894e37973c2c64c83
BLAKE2b-256 def5059c36e983caf8b5a0f1625ec4d2e56abbb8d2b498a5634ce2155b582597

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page