Timer

From LemonWiki共筆
Revision as of 14:28, 8 December 2016 by Planetoid (talk | contribs)
Jump to navigation Jump to search

Get the execution time of the script or sql query was executed.

PHP

Start and stop a timer PHP - Stack Overflow


MySQL

Recording the time elapsed after the sql query was executed.

SELECT @timer := CURRENT_TIMESTAMP();
SELECT SLEEP(2); /* sleep 2 seconds for testing purpose */
SELECT 'custom message' AS 'action', CURRENT_TIMESTAMP() AS 'end time', @timer AS 'start time', TIMEDIFF(CURRENT_TIMESTAMP(), @timer) AS 'time elapsed';

Linux command

Linux Os linux.png console, Mac icon_os_mac.png Terminal or Cygwin commands on Win Os windows.png [1]

START=$(date +%s)

# sleep 2 seconds for testing purpose
sleep 2s

END=$(date +%s)
DIFF=$(( $END - $START ))
echo "Elapsed time $DIFF seconds"

Python

performance - Measure time elapsed in Python? - Stack Overflow


References