cpu and bus speed report

View previous topic View next topic Go down

cpu and bus speed report

Post  zzajin on Thu Nov 06, 2008 10:37 pm

Apparently 1st and 2nd gen touch devices have different cpu and bus speeds: 412Mhz cpu with 103Mhz bus and 532Mhz cpu with 133Mhz bus respectively.

During init sio2 gives a bit of a report. Here is some code for cpu and bus speeds that might be of use to someone.


Code:

   
#include <sys/sysctl.h>


   int mib[6] = { 0 };
   size_t length = sizeof( int );
   
   int cpuF = 0;
   int busF = 0;
   
   // Get cpu speed
   mib[0] = CTL_HW;
   mib[1] = HW_CPU_FREQ;
   sysctl( mib, 2, &cpuF, &length, 0,0 );
   
   
   // Get bus speed
   mib[0] = CTL_HW;
   mib[1] = HW_BUS_FREQ;
   sysctl( mib, 2, &busF, &length, 0,0 );
   
   
   printf( "\nCPU speed: %d Mhz\n", cpuF/1000000 );
   printf( "Bus speed: %d Mhz\n", busF/1000000 );



zzajin

Posts : 81
Join date : 2008-10-14

View user profile

Back to top Go down

Re: cpu and bus speed report

Post  sio2interactive on Sat Nov 08, 2008 1:58 am

Once again tks for the tip man! Will integrate the code at init time Wink


Cheers,
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: cpu and bus speed report

Post  matt on Sat Nov 08, 2008 1:21 pm

Then it would be probably nice to have information about available memory, too. I dump this information every five seconds in debug build just to have an idea where the memory goes even when not explicitly hunting for memory leaks.

Code:
   int pagesize;
   mib[ 0 ] = CTL_HW;
   mib[ 1 ] = HW_PAGESIZE;
   size_t length = sizeof(pagesize);
   if( sysctl( mib, 2, &pagesize, &length, NULL, 0 ) < 0 ) {
      // Failure!
      return;
   }
   mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
   vm_statistics_data_t vmstat;
   if( host_statistics( mach_host_self(), HOST_VM_INFO, (host_info_t) &vmstat, &count ) != KERN_SUCCESS ) {
      // Failure!
      return;
   }
   NSLog( @"Free memory: %8d bytes", vmstat.free_count * pagesize );

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

View user profile http://elfrun.net

Back to top Go down

Re: cpu and bus speed report

Post  sio2interactive on Sat Nov 08, 2008 4:02 pm

For memory leaks, you can use instruments, or sio2_memory, that will detect and report you the leaks as well as where in your code this memory have been initialized and the total memory currently in use...

Cheers,
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: cpu and bus speed report

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum