#include <errno.h> #ifndef NONAMESPACE #include <iostream> using namespace std; #else #include <iostream.h> #endif #include <string> #include "extremes.h" #include "funcnames.h" #include "funcstats.h" FuncNames::FuncNames() { nfuncs = 0; } string *FuncNames::GetName( int ifuncname ) { return names[ifuncname]; } FuncStats *FuncNames::GetStats( int ifuncname ) { return stats[ifuncname]; } bool FuncNames::Find( string name, int *ifuncname ) { int ilower; int iupper; bool found; int imiddle; string str; ilower = 0; iupper = nfuncs - 1; found = false; if( ilower <= iupper ) { do { imiddle = ilower + ( ( iupper - ilower ) / 2 ); str = *names[imiddle]; if( name < str ) iupper = imiddle - 1; else if( name > str ) ilower = imiddle + 1; else found = true; } while( ilower <= iupper && !found ); if( !found && name > str ) imiddle++; } else imiddle = 0; *ifuncname = imiddle; return found; } int FuncNames::Insert( string name, int ifuncname ) { int jfuncname; int nelements; int j; jfuncname = ifuncname + 1; nelements = nfuncs - ifuncname; nfuncs++; if( nfuncs > MAXFUNCS ) { cout << "nfuncs > MAXFUNCS\n"; return ENOMEM; } memmove( &names[jfuncname], &names[ifuncname], nelements * sizeof( names[0] ) ); memmove( &stats[jfuncname], &stats[ifuncname], nelements * sizeof( stats[0] ) ); names[ifuncname] = new string( name ); stats[ifuncname] = new FuncStats( ifuncname ); for( j = jfuncname; j < nfuncs; j++ ) stats[j]->SetIFuncName( j ); return 0; } void FuncNames::Print() { int i; FuncStats *funcstats; for( i = 0; i < nfuncs; i++ ) { funcstats = stats[i]; if( funcstats->GetNComputes() || funcstats->GetNElapseds() ) { cout << "Function: " << *names[i] << "\n"; funcstats->Print(); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 5389 | Shawn Hladky | Branching p4loga for modifications | ||
//guest/michael_shields/src/p4loga/funcnames.cc | |||||
#2 | 1722 | Michael Shields |
p4loga builds for freebsd4 (play), hpux11 (hell), linux24x86 (duey), and solaris26 (shucks). A bit of porting was required for the hpux11 build (aCC as configured on hell isn't quite up to speed with respect to namespaces). |
||
#1 | 1610 | Michael Shields |
Adding p4d log analyzer concocted by myself. Compiles and executes on Red Hat 6.0, 7.0, and probably a few other operating systems with perhaps a little help. Still needs comments. |