Chris
Chris

Reputation: 10041

How do I time execution duration of a program or script from the command line?

I'm learning C and would like to get a sense for just how much faster some of my C code is than its python equivalent.

I'm running Ubuntu 12.04

Upvotes: 0

Views: 289

Answers (2)

rakib_
rakib_

Reputation: 142545

From command line you can use "time" command. This will give you the execution time of that program in three separate mode (by default) - a. real time; b. user time; c. system time.

a. real time indicates how much time it took overall; b. user time indicates how much time it took executing at userspace c. system time indicates how much time it took executing at kernel space.

Above is the way to measure time from commnad line. You can also measure program execution time from in program - using system call like gettimeofday().

Upvotes: 2

Marcus Ilgner
Marcus Ilgner

Reputation: 7211

You have the answer to your question there in the title: the time command will measure the time it takes for a command to complete.

Upvotes: 1

Related Questions