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.

Files for cmdtime, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size cmdtime-0.0.4.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page