# time(1) how to compare speed



## Alt (Jun 15, 2010)

I want to compare 2 versions of same program - im trying to optimize them for speed/cpu use.
Now i tested 2 versions of and got output from time(1), but i cant understand how to compare these data wisely :\
Got 3 test for each version, version1:
	
	



```
0.043u 0.208s 0:02.26 10.6%     9+1008k 0+0io 0pf+0w
0.031u 0.203s 0:02.62 8.7%      13+1340k 0+0io 0pf+0w
0.193u 0.109s 0:02.74 10.5%     0+839k 0+0io 0pf+0w
```
version2:
	
	



```
0.167u 0.101s 0:02.60 10.0%     7+948k 0+0io 0pf+0w
0.098u 0.110s 0:01.94 10.3%     1+947k 0+0io 0pf+0w
0.137u 0.068s 0:01.90 10.0%     2+1175k 0+0io 0pf+0w
```

I know(by code design) version2 IS faster, but i need to know how to measure by howmuch percent.

Sry for bad english. Thanks.


----------



## graudeejs (Jun 15, 2010)

you need to use some kind of profiling for testing this kind of stuff
http://en.wikipedia.org/wiki/Profiling_(computer_programming)


----------



## phoenix (Jun 15, 2010)

Use time(1) (/usr/bin/time) and not the built-in time function of the shell.  And add *-h* to get human-readable times:

`$ /usr/bin/time -h /path/to/command`


----------

