Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Awk profiler 1

Status
Not open for further replies.

marsd

IS-IT--Management
Apr 25, 2001
2,218
US
I was reading an old programming text today,
"More Programming Pearls", by Jon Bentley,
and saw a section on building profilers,
one in awk.

Has anyone done any profiling of their code
here, and how would you go about building one
for awk?
 
what's a 'profiler'?

Any URL you can share, marsd? vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Hi Vlad.

No urls: the book was released circa 88.

The profiling was just a way of finding where your
program was spending most of it's time. Most of the
scripts here are short, but for some larger awk
programs and for tshooting I thought that a profiler
might be very helpful.

You would wrap your script in the profiler script,
exec it and the profiler would keep track of how much
time was spent in each control section.

say this output:
BEGIN { ((1 time))
n = 1000
xarr[0] = 1 ; x = 1
print 2
for (i = 1 ; i <= n ; i++) { ((998 times))
if (prime(i)) { ((167 times))
print i
}
}
exit
}

Have you seen any examples of programs that do this?
The book says that his awk profiler scripts were two five line programs but he doesn't include them...

 
hi!

nope, I've not seen anything like that for awk.

PLS let us all know if you find anything worth sharin'!

vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
It was right in front of me the whole time.
Gawk ships with pgawk, doh...

`pgawk' is identical in every way to `gawk', except that when it has
finished running, it creates a profile of your program in a file named
`awkprof.out'. Because it is profiling, it also executes up to 45
percent slower than `gawk' normally does.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top