Questions tagged [execution-time]

Execution time refers to how long it takes a particular program to execute.

Use this tag for questions related to measuring or improving the execution time of a particular piece of code.

724 questions
1705
votes
39 answers

How do I get time of a Python program's execution?

I have a command line program in Python that takes a while to finish. I want to know the exact time it takes to finish running. I've looked at the timeit module, but it seems it's only for small snippets of code. I want to time the whole program.
john2x
  • 22,546
  • 16
  • 57
  • 95
1012
votes
42 answers

How do I time a method's execution in Java?

How do I get a method's execution time? Is there a Timer utility class for things like timing how long a task takes, etc? Most of the searches on Google return results for timers that schedule threads and tasks, which is not what I want.
Ogre Psalm33
  • 21,366
  • 16
  • 74
  • 92
247
votes
4 answers

How to increase maximum execution time in php

I want to increase maximum execution time in php , not by changing php.ini file. I want to Increase it from my php file. Is this possible?
Pritesh Mahajan
  • 4,974
  • 8
  • 39
  • 64
170
votes
11 answers

Find out time it took for a python script to complete execution

I have the following code in a python script: def fun(): #Code here fun() I want to execute this script and also find out how much time it took to execute in minutes. How do I find out how much time it took for this script to execute ? An…
James
  • 1,701
  • 2
  • 11
  • 3
136
votes
12 answers

Maximum execution time in phpMyadmin

When I try to execute (some) queries in phpMyadmin I get this error Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\phpmyadmin\libraries\dbi\mysql.dbi.lib.php on line 140 because I have a very large table (over 9 millions…
ahmed
  • 14,316
  • 30
  • 94
  • 127
87
votes
11 answers

How to solve time out in phpmyadmin?

I want import huge (at least 300 mb) sql scripts via phpMyAdmin. I've tried: post_max_size = 750M upload_max_filesize = 750M max_execution_time = 300 max_input_time = 540 memory_limit = 1000M in my php.ini file, but I'm still getting timeout errors…
user1811486
  • 1,294
  • 2
  • 10
  • 17
86
votes
4 answers

What is the best way to measure execution time of a function?

Obviously I can do and DateTime.Now.After - DateTime.Now.Before but there must be something more sophisticated. Any tips appreciated.
Ian G
  • 29,468
  • 21
  • 78
  • 92
75
votes
4 answers

Loop with a zero execution time

Is it possible to have a loop which has a zero execution time? I would think that even an empty loop should have an execution time since there is an overhead associated with it.
SudarakaR
  • 937
  • 6
  • 6
60
votes
5 answers

Is there an efficient way to calculate execution time in golang?

I'm looking for the best way to calculate execution time in go. func main() { start := time.Now() time.Sleep(time.Second * 2) //something doing here elapsed := time.Since(start) fmt.Printf("page took %s", elapsed) } The code…
Özgür Yalçın
  • 1,872
  • 3
  • 16
  • 26
54
votes
9 answers

calculating execution time in c++

I have written a c++ program , I want to know how to calculate the time taken for execution so I won't exceed the time limit. #include using namespace std; int main () { int st[10000],d[10000],p[10000],n,k,km,r,t,ym[10000]; k=0; …
Hick
  • 35,524
  • 46
  • 151
  • 243
45
votes
7 answers

Why is this Java code 6x faster than the identical C# code?

I have a few different solutions to Project Euler problem 5, but the execution time difference between the two languages/platforms in this particular implementation intrigues me. I didn't do any optimization with compiler flags, just plain javac…
rianjs
  • 7,767
  • 5
  • 24
  • 40
40
votes
1 answer

Difference between Rscript and littler

...besides the fact that Rscript is invoked with #!/usr/bin/env Rscript and littler with #!/usr/local/bin/r (on my system) in first line of script file. I've found certain differences in execution speed (seems like littler is a bit slower). I've…
aL3xa
  • 35,415
  • 18
  • 79
  • 112
39
votes
8 answers

Measure execution time in C#

I want to measure the execution of a piece of code and I'm wondering what the best method to do this is? Option 1: DateTime StartTime = DateTime.Now; //Code TimeSpan ts = DateTime.Now.Subtract(StartTime); string elapsedTime =…
Jake
  • 393
  • 1
  • 3
  • 4
33
votes
10 answers

PHPUnit print tests execution time

is there a way to print the execution time of each test with PHPUnit?
mck89
  • 18,918
  • 16
  • 89
  • 106
31
votes
3 answers

How to get the execution time of a MySQL query from PHP?

I execute MySQL queries from PHP and would like to know how time consuming they are. Is there any way to get the execution time of a MySQL query from PHP? I also wonder if the execution time depends on how loaded is the web server. I can imagine…
Roman
  • 124,451
  • 167
  • 349
  • 456
1
2 3
48 49