Similar to Linux `time` utility useful for Windows Command Prompt using pure Python
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cmdtime-0.0.3.tar.gz
.
File metadata
- Download URL: cmdtime-0.0.3.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3e29ab030fbec1034e4836174115f6ffddc99df7a00e4988425ad7e01c7f88e |
|
MD5 | 9c996312d1d55fe318d690602b6e2052 |
|
BLAKE2b-256 | 3148b5a668196dc95bb0193189cfb1cbe3c42907fe0e4659f386e7a129a17782 |