05-20-2009
45,
0
Join Date: Feb 2009
Last Activity: 30 June 2009, 11:54 PM EDT
Posts: 45
Thanks Given: 0
Thanked 0 Times in 0 Posts
can you design/create a script for this?
Hello ALL,
I have a file say test.txt, data in that file is in format such that
1st column represents number of executions of particular function
2nd column represents total amount of time
3rd column represents function name
I want to get the poor/slow performing function from this file.
So, ideally what need to do is...
(1) divide the 2nd column by 1st column
(make sure there is no divide by ZERO error)
(2) sort the output in such a way that the record with greater output of step(1) is at top
(3) depending on this sorting display the result file.
result should not contain the division but should contain the original value.
example...
inputfile...
$ cat test.txt
3 (0 sec, 804275 nanosec) abcd
721 (253 sec, 632655866 nanosec) efgh
1873 (21 sec, 887264375 nanosec) hijk
2006 (0 sec, 922300 nanosec) lmhn
3 (0 sec, 3332 nanosec) sjhfdf
2 (0 sec, 2367 nanosec) dkfi
580 (0 sec, 2138703 nanosec) dfhjf
44486 (0 sec, 858447770 nanosec) oet
21102 (739 sec, 891470054 nanosec) lldff
140 (0 sec, 90282 nanosec) sfowe
123 0 sec, 324590 nanosec) xjjv
8939 (0 sec, 337230856 nanosec) asadj
19 (0 sec, 1455434 nanosec) sahjdi
210 (0 sec, 89131 nanosec) posdio
3 (0 sec, 3750149 nanosec) jhd
873 (260 sec, 715043557 nanosec) lppeuv
16 (0 sec, 212024 nanosec) hjass
13668 (2 sec, 506391927 nanosec) nnuua
-------------<end of file>------------------------
here... after division we see these are greater...
253/721 = 0.35090152
260/873 = 0.29782359
so output should look like...
721 (253 sec, 632655866 nanosec) efgh
873 (260 sec, 715043557 nanosec) lppeuv
.
.
likewise...