Groups | Search | Server Info | Login | Register
| Date | 2011-04-10 23:05 -0400 |
|---|---|
| From | Mike Rhodes <M8R-1cd059@mailinator.com> |
| Newsgroups | comp.lang.awk |
| Subject | gnuplot algorithm help |
| Message-ID | <4da27014$0$669$c3e8da3$b280bf18@news.astraweb.com> (permalink) |
| Organization | Unlimited download news at news.astraweb.com |
Hello fellow AWKers,
I'm trying to use output from nfdump to plot total throughput in gnuplot
but I am having trouble coming up with the correct algorithm.
Given a datafile organized this way...
# START_TIME MBPS DUR
1302350771.016 0.003040 1.752
1302350788.681 0.047432 4.548
1302350792.845 0.032472 1.120
1302350792.901 0.021536 0.172
1302350793.217 0.023680 0.420
1302350800.717 0.025024 0.492
1302350814.777 0.001248 0.000
1302350814.781 0.001248 0.020
1302350823.701 0.019568 0.228
1302350830.432 0.000832 0.096
...I'm trying to keep a running total of Mbps when two times overlap. In
other words, when $1 is less than any previous $1+$3 then $2 should be
added to the $2 of all of the the records with the larger $1+$3.
Here's what I've come up with so far:
{
print
longest = $1 + $3
tput = $2
getline
while ($1 < longest) {
tput += $2
print $1, tput, $3
getline
}
print
}
The obvious flaw here is that two lines are printed in a row without any
tests being applied when the while loop is broken. I've been unable to
come up with an algorithm that allows me to do the comparison I need but
doesn't swallow any output via unprinted getlines. I know that getline
is considered an "advanced" function, but I'm hoping someone here has
enough experience with it to help me on this.
Thank you,
Mike
Back to comp.lang.awk | Previous | Next — Next in thread | Find similar
gnuplot algorithm help Mike Rhodes <M8R-1cd059@mailinator.com> - 2011-04-10 23:05 -0400
Re: gnuplot algorithm help Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-04-11 10:30 +0200
Re: gnuplot algorithm help Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-04-11 12:06 +0200
Re: gnuplot algorithm help Mike Rhodes <M8R-1cd059@mailinator.com> - 2011-04-11 06:11 -0400
Re: gnuplot algorithm help Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-04-11 14:40 +0200
Re: gnuplot algorithm help Mike Rhodes <M8R-1cd059@mailinator.com> - 2011-04-11 12:29 -0400
Re: gnuplot algorithm help Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-04-11 19:51 +0200
Re: gnuplot algorithm help Mike Rhodes <M8R-1cd059@mailinator.com> - 2011-04-11 19:42 -0400
csiph-web