ggat
ggat

Reputation: 472

NYTProf execution time when profiling and when no profiling

Just, wanted to make sure.

I have small python script that measures program execution time, it simply saves time before external program starts and then substracts this value from time after program ends execution.

When running this script on perl script it shows execution time of 0.49263 and when running same script with NYTProf and looking inside HTML report generated by nytprofhtml I can see that execution time is 0.80784, almost twice more.

Is this OK? I suppose profiling should increase execution time but that much?

Upvotes: 1

Views: 207

Answers (1)

simbabque
simbabque

Reputation: 54333

This is normal because Devel::NYTProf needs to look at every single statement (and blocks, and so on). It needs to write profiling data to disk for each statement. The cost for this is quite high. That's why you should not run it in production.

There's some info on how to make it run faster in the documentation.


If you run on a linux command line, there is no need for any other programs to get the execution time of a command. Simply do this on the shell:

$ time perl foo.pl

Upvotes: 2

Related Questions