00001 /* 00002 * See the dyninst/COPYRIGHT file for copyright information. 00003 * 00004 * We provide the Paradyn Tools (below described as "Paradyn") 00005 * on an AS IS basis, and do not warrant its validity or performance. 00006 * We reserve the right to update, modify, or discontinue this 00007 * software at any time. We shall have no obligation to supply such 00008 * updates or modifications or any other form of support to you. 00009 * 00010 * By your use of Paradyn, you understand and agree that we (or any 00011 * other person or entity with proprietary rights in Paradyn) are 00012 * under no obligation to provide either maintenance services, 00013 * update services, notices of latent defects, or correction of 00014 * defects for Paradyn. 00015 * 00016 * This library is free software; you can redistribute it and/or 00017 * modify it under the terms of the GNU Lesser General Public 00018 * License as published by the Free Software Foundation; either 00019 * version 2.1 of the License, or (at your option) any later version. 00020 * 00021 * This library is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00024 * Lesser General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU Lesser General Public 00027 * License along with this library; if not, write to the Free Software 00028 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00029 */ 00030 00031 00032 // $Id: timing-aix.C,v 1.10 2007/05/30 19:20:30 legendre Exp $ 00033 #include "common/h/timing.h" 00034 #include <stdio.h> 00035 #if defined(XLC) && defined(USE_PMAPI) 00036 #include <pmapi.h> 00037 #endif 00038 00039 00040 double calcCyclesPerSecond_sys() { 00041 /* We have a function pm_cycles which returns the time in a double */ 00042 #if defined(USE_PMAPI) 00043 double cycles = pm_cycles(); 00044 #else 00045 double cycles = 0; 00046 #endif 00047 00048 // A bit of a hack: I've seen pm_cycles returning abnormally low values 00049 // (34 cps?) on AIX 5.1 machines. If this value isn't sensible, return 00050 // as MethodNotAvailable 00051 if (cycles < 1000) { 00052 cerr << "WARNING: pm_cycles returned nonsensical value of " << cycles 00053 << ", using default method to determine CPS." << endl; 00054 return cpsMethodNotAvailable; 00055 } 00056 if (cycles == 0.0) 00057 return cpsMethodNotAvailable; 00058 return cycles; 00059 } 00060 00061 double calcCyclesPerSecondOS() 00062 { 00063 double cps; 00064 cps = calcCyclesPerSecond_sys(); 00065 if(cps == cpsMethodNotAvailable) { 00066 return 0.0f; 00067 } 00068 return cps; 00069 } 00070
1.6.1