Showing posts with label time. Show all posts
Showing posts with label time. Show all posts

4/22/2022

Measuring processing time python

 Measure processing time


..

#metho #1
import time
start = time.time()
print("hello")
end = time.time()
print(end - start)


#method #2
from timeit import default_timer as timer
start = timer()
# ...
end = timer()
print(end - start) # Time in seconds, e.g. 5.38091952400282

..


Thank you.

www.marearts.com


9/21/2020

python measure processing time

 


from time import process_time
# Start the stopwatch / counter
t1_start = process_time()

###
#processing
###

# Stop the stopwatch / counter
t1_stop = process_time()
sec = t1_stop-t1_start


7/07/2020

extract year, month, day from file on Ubuntu, python example


...
import os, time
date_created_obj = time.localtime(os.path.getctime(full_path))
print('Year: {:4d}'.format(date_created_obj.tm_year)) # Year: 2020
print('Month: {:2d}'.format(date_created_obj.tm_mon)) # Month: 2
print('Day: {:2d}'.format(date_created_obj.tm_mday)) # Day: 10

...


12/14/2016

ctime_s and ctime example


#include < time.h >
#include < stdio.h >

int main(void)
{
time_t result = time(NULL);
//printf("%ld \n", result);
//printf("%s \n", ctime(&result));

char str[26];
ctime_s(str,sizeof str,&result);
printf("%s \n", str);

}


-> result
Thu Dec 15 02:29:54 2016