Ask coding questions

← Back to all posts
Running time
MansourQuzmar1 (0)

How can i know running time of my program on replit

Comments
hotnewtop
ANDREWVOSS (188)

get the time at the start and end of your program, in python use

import time
start_time = time.time()
#run your program
end_time = time.time()
print(end_time-start_time)

In C/C++ you can use

#include <time.h>

int main() {
  clock_t start_time = clock();
  //run your program
  clock_t end_time = clock();
  printf("%f",((float)t)/CLOCKS_PER_SEC);
}
btfuss (178)

Somehow figure out exactly what time you started your program,
and on the last line of code print out: [the time it is] - [start of program time]