Skip to content

Time Execute in Jupyter and Bash

 result=$(( TIMEFORMAT='%3R'; time ( sleep 1 ) ) 2>&1)
 echo "Execution time." > /tmp/.timeit.txt
 gdate -u -d @"$result" +"%T" >> /tmp/.timeit.txt
 send2email your@email.com "Ready to watch" /tmp/.timeit.txt
TIMEFORMAT='%3R'; time ( sleep 1 ) 2> /tmp/test.txt

result=$(( TIMEFORMAT='%3R'; time ( sleep 1 ) ) 2>&1) ; echo $result
#Linux
date -u -d @"$result" +"%T"
#Mac
gdate -u -d @"$result" +"%T"

https://www.cyberciti.biz/faq/unix-linux-time-command-examples-usage-syntax/

/usr/bin/time -o output.time.txt -f '%E' sleep 1
cat output.time.txt 

Jupyter on Windows 10

import time
import datetime
start = time.time()
%time time.sleep(3)

Wall time: 3 s
end = time.time()
#print(end - start)
conversion = datetime.timedelta(seconds=(end - start))
converted_time = str(conversion)
print(converted_time)

0:00:03.018675
import datetime
delta1 = datetime.timedelta(days=10, seconds=1)
delta2 = datetime.timedelta(days=1, seconds=10)
print delta1 + delta2
Output
11 days, 0:00:11
print delta2 - delta1
Output
-9 days, 0:00:09
print -delta2
Output
-2 days, 23:59:50
print delta1 / 2
Output
5 days, 0:00:00.500000
print delta1 * 3
Output
30 days, 0:00:03
print(seconds_input)

Output

3665

conversion = datetime.timedelta(seconds=seconds_input)

Convert seconds to timedelta object


converted_time = str(conversion)

Convert timedelta to a string

print(converted_time)

Output

1:01:05

Jupyter on Linux

import time
start = time.time()
%time time.sleep(3)
end = time.time()
#print(end - start)
Diff=(end - start)
!date -u -d @"$Diff" +"%T"
!echo "Time Execute in Jupyter" > /tmp/diff.txt
!date -u -d @"$Diff" +"%T" >> /tmp/diff.txt
!email sarayut@beenplus.com /tmp/diff.txt
#!email sarayut@beenplus.com /dev/null
#jupyter notebook password
jupyter lab --port=12345 --no-browser
#Jupyter lab on Ubuntu 18.04 AMD
#Merged.ipynb
00:21:42
#Dynamic Merged Pipeline.ipynb
02:24:31
# Firefox remote
#Merged.ipynb
00:21:14
#Dynamic Merged Pipeline.ipynb
02:24:24
#jupyter notebook
#jupyter notebook password
jupyter notebook --port=12345 --no-browser
jupyter notebook --ip='*' --port=12345 --no-browser
#Jupyter lab on Ubuntu 18.04 AMD
#Firefox remote
Joy-Preg Seurat_Velocity Pipeline Merged
00:21:31
Joy-Dynamic Merged Pipeline
02:24:04
#jupyter notebook in Docker winuthayanonlab/scrna-seq on AMD Ubuntu 18.04
#jupyter notebook password
#jupyter lab password
#jupyter notebook --port=12345 --no-browser
jupyter notebook --ip='*' --port=12345 --no-browser
pip install jupyterlab
jupyter lab --ip='*' --port=12345 --no-browser
#Jupyter lab on Ubuntu 18.04 AMD
#Firefox remote
Pipeline Merged
jupyter lab      vs      jupyter notebook
 00:22:37                   00:22:45
Dynamic Merged Pipeline
jupyter lab      vs      jupyter notebook
 02:48:17

Bash on Linux

date --date="Sat May  9 20:15:57 PDT 2020" '+%s'
date --date="Sat May  9 20:37:12 PDT 2020" '+%s'
date -d @1589080557
date -d @1589081832
echo "$((1589081832-1589080557))"
date -u -d @1275 +"%T"

Start=`date --date="Sat May  9 20:15:57 PDT 2020" '+%s'`
Stop=`date --date="Sat May  9 20:37:12 PDT 2020" '+%s'`
Diff="$(($Stop-$Start))"
echo $Diff
date -u -d @"$Diff" +"%T"

Start=`date '+%s'`
sleep 3
Stop=`date '+%s'`
Diff="$(($Stop-$Start))"
echo $Diff
date -u -d @"$Diff" +"%T"

Bash on Mac

Start=`gdate '+%s'`
sleep 3
Stop=`gdate '+%s'`
Diff="$(($Stop-$Start))"
echo $Diff
gdate -u -d @"$Diff" +"%T"
Published inUncategorized

4 Comments

  1. Ezequiel Ezequiel

    Usually I don’t learn article on blogs, but I would like to say that this write-up
    very forced me to try and do so! Your writing style
    has been amazed me. Thank you, very nice post.

  2. judi kartu idnpoker judi kartu idnpoker

    Hi there! Someone in my Myspace group shared this site with us so
    I came to take a look. I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to
    my followers! Fantastic blog and fantastic
    design.

  3. tai kucing tai kucing

    Wonderful beat ! I wish to apprentice at the same time as you amend
    your site, how can i subscribe for a blog site?
    The account aided me a applicable deal. I have been a
    little bit acquainted of this your broadcast provided vivid transparent concept

  4. TheIndianTimes TheIndianTimes

    Thankis to my father whoo informed me regarding this web site, this webpage is actually awesome.

Leave a Reply to Ezequiel Cancel reply

Your email address will not be published. Required fields are marked *