# TAWK Program Profiler # Part 1 of 2 (Profiler utility) # Copyright (C) 1996 QUERE Jean-Marc # Email: quere@worldnet.fr # # I give you ( THOMPSON ) the autorization to post this sources as is # in your WebSite and registred users of TAWK to use them as they want. # Don't remove my name into the sources and said that I do it on the page. # # step 1 # link this program with your own program like this : "awkc profiler my_program" # after running the program "profiler.exe", a file called "profiler.tmp" # is created. # step 2 # Run "profdisp", (in the same directory) # and have a look on the resulting file "profiler.res" with MS-DOS edit or another editor... # local profil_tab,profil_gid,profil_fic,profil_ofs,profil_siz,profil_pos=-1 local profil_str INIT { local i,tmpa if ((profil_fic=fopen("PROFILER.TMP","w+"))!=-1) { for (i in FUNINFO) { split(FUNINFO[i],tmpa," ") if (tmpa[1] ~ /(^|:)profiler/) { profil_gid = i; } fwrite(sprintf("%06d",i) "\t" tmpa[1] "\t" tmpa[2] "\t" tmpa[3] "\n",profil_fic) } fwrite("\n",profil_fic) profil_ofs=ftell(profil_fic) profil_siz=length(sprintf("%06d\t%06d\t%06d\t%06d\n",0,0,0,0)) debug_function("profiler") } } function profiler(gid,linenum) { local tmpa,sec if (gid > profil_gid) { profil_str=sprintf("%06d\t%06d",gid,linenum) if (profil_str in profil_tab) { fseek(profil_fic,profil_pos=profil_tab[profil_str],0) profil_str=fread(profil_siz,profil_fic) split(profil_str,tmpa,"\t") tmpa[3]++ profil_str=sprintf("%06d\t%06d\t%06d\t%06d\n",tmpa[1],tmpa[2],tmpa[3],tmpa[4]) } else { fseek(profil_fic,0,2) profil_pos=ftell(profil_fic) profil_tab[profil_str]=profil_pos profil_str=profil_str sprintf("\t%06d\t%06d\n",1,0) } fseek(profil_fic,profil_pos,0) fwrite(profil_str,profil_fic) } debug_function("profiler") }