I have a file with the following values:
for 3 threads: Average time taken for API1 is: 19097.7 nanoseconds. Average time taken for API2 is: 19173.1 nanoseconds. Average time taken for API2 is: 19777.7 nanoseconds. Average time taken for API2 is: 19243.1 nanoseconds. Average time taken for API1 is: 19737.7 nanoseconds. Average time taken for API2 is: 19128.1 nanoseconds. for 5 threads: Average time taken for API1 is: 19097.7 nanoseconds. Average time taken for API2 is: 19173.1 nanoseconds. Average time taken for API2 is: 19777.7 nanoseconds. ...
I wish to calculate the sum of the 1API lines and the 2API lines, and sum them. Another requirement is that i also want to figure out for each thread on a separate basis. Is there a way to do this using perl, sed, awk or just shell scripts?
What I can current get is:
cat result | grep API1 | awk {'print $7'}
You can use a combination of grep en awk. grep to select only the lines with data (where API is in) and awk for the counting.
(change file with filename or remove for reading from stdin)
If you want to calculate the different sums you can do this
Output: