A console/terminal demo of measuring elapsed time in Python: read the clock with time.time() before and after a piece of work — here a sleep — and print the difference. It is the simplest way to find out how long any part of a program actually takes. Runs on Windows 11 and Ubuntu Linux 24.04, uses the standard library only — no third-party packages, no GPU, fully offline.

 

[Folder Structure]

  • CLAUDE.md / AGENT.md: program specification (identical content).
  • CHANGELOG.md: change log.
  • copyright.txt: copyright notice.
  • src/: the example, the launcher scripts, and this document.
  • venv/: Python virtual environment, created by step 1.

[Prerequisites]

  • Operating system: Windows 11 or Ubuntu Linux 24.04.
  • Python 3 and pip.
  • No third-party packages — the example uses the standard library only.
  • No internet connection and no GPU required.

[Instructions]

Step 1: Create the virtual environment

Create the virtual environment. Because the example uses only the standard library, this step installs no extra packages.

 

Windows 11:

src\01_venv_create.bat

Ubuntu Linux 24.04:

bash src/01_venv_create.sh

Step 2: Activate the virtual environment

Activate the environment in the current shell. On Linux you must source the script so the activation stays in effect after it finishes.

 

Windows 11:

src\02_venv_activate.bat

Ubuntu Linux 24.04:

source src/02_venv_activate.sh

Step 3: Measure the elapsed time

Run the demo. It records the time, sleeps, records the time again, and prints how many seconds passed. Extra arguments are forwarded to the program, so you can change how long it waits.

 

Windows 11:

src\03_timer.bat

Ubuntu Linux 24.04:

bash src/03_timer.sh

Step 4: Remove the virtual environment

When you are finished, delete the venv/ folder to free up disk space. Re-run step 1 whenever you need the environment again.

 

Windows 11:

src\99_venv_clear.bat

Ubuntu Linux 24.04:

bash src/99_venv_clear.sh

[Usage Notes]

  • The pattern is always the same: save the time before, run the work, subtract. The result is in seconds, as a floating-point number.
  • time.time() returns wall-clock time, which is what you want when reporting how long something took the user to wait.
  • The measured time is never exactly the requested sleep — a few milliseconds go into starting the sleep and waking up again, and the operating system may schedule other work in between.
  • For timing very short pieces of code, run them many times in a loop and divide: a single run is dominated by measurement noise.

This SDK is built in AppForAI - AI Dev Tools.

 

Purchase license separately:  USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.