Apple start page CPU toll?

Discussion in 'macOS' started by cody92, May 3, 2013.

  1. cody92 macrumors newbie

    Joined:
    May 3, 2013
    #1
    Apples start page has that count to the 50 billion app downloads and it's causing about 25% CPU usage on my macbook air. I know it's not much(about 1/16 of my total CPU power) but I would think they could do better than that. GIFs usually do less than that. Maybe I'm just nuts but I thought apple was good at making things efficient. I haven't looked into the method they are using to do the incrementing image. Anybody got a better idea for them for less CPU usage? (I realize they probably don't care because this is just a page people will not spend much time on, but this is for a fun challenge to anybody interested) :)

    If there isn't a better way, why?
     
  2. Drew017 macrumors 65816

    Drew017

    Joined:
    May 29, 2011
    Location:
    East coast, USA
    #2
    Umm the flip counter is pretty small. When I visit the webpage it uses no more cpu power than any other web page… in fact looking at activity monitor i'm only using 7% of my CPU with two tabs open on safari, mail running, and iTunes open.

    Also, if it used 25% of your CPU, wouldn't that be 1/4th… not 1/16th?
     
  3. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #3
    It's very likely there's something else causing that usage. Follow every step of the following instructions precisely. Do not skip any steps.
    1. Launch Activity Monitor
    2. Change "My Processes" at the top to "All Processes"
    3. Click on the "% CPU" column heading once or twice, so the arrow points downward (highest values on top).
      (If that column isn't visible, right-click on the column headings and check it, NOT "CPU Time")
    4. Click on the System Memory tab at the bottom.
    5. Take a screen shot of the entire Activity Monitor window, then scroll down to see the rest of the list, take another screen shot
    6. Post your screenshots.
     
  4. cody92, May 3, 2013
    Last edited: May 3, 2013

    cody92 thread starter macrumors newbie

    Joined:
    May 3, 2013
    #4
    The counter will only process if that tab is currently selected, otherwise you won't see anything being processed. Basically, make sure you can see the counter. It's not going to waste cpu cycles rendering something that doesn't need rendered.

    Also 100% CPU means 100% of ONE core. A dual core processor with hyper-threading has 4 logical cores total. Meaning 400% is max CPU. If you write a program that spins 4 threads you will see that process using about 399% CPU.
    Finally 25%/400% = 1/16.
     
  5. cody92 thread starter macrumors newbie

    Joined:
    May 3, 2013
    #5
    I can confirm that top process is the one processing the start page content. It's actually highly likely that this is what's causing the usage. It makes sense, I just wanted to see if anybody had a more efficient solution. Thanks for the tips on posting images to the forums.

    forum.png
     
  6. cody92, May 3, 2013
    Last edited: May 3, 2013

    cody92 thread starter macrumors newbie

    Joined:
    May 3, 2013
    #6
    Oh about the previous post using 400% CPU. If you want to see it for yourself, I wrote a program that finds all the prime numbers for a 64-bit signed long(this program probably won't complete in the next 10 years especially since it's purposefully inefficient) and the source is below and it's very easy to compile and run.

    (By the way this is a very inefficient way to count the primes. Algorithm analysis will probably put this at Big Theta of n^3 That's the point for this exercise tho :) )

    To compile:

    1. Copy and paste the text below into a file called main.c and save it to a directory.

    2. Open the terminal and navigate to that same directory.

    3. Type: gcc main.c -o prime.out

    4. Now type: ./prime.out

    5. Look at your activity monitor. High 300%!!!

    6. Go back to your terminal and press Control + C to kill the process.

    Code:
    //
    //  main.c
    //  MultiThreaded test
    //
    //  Created by Cody Rigney on 2/4/13. Updated 5/3/13.
    //  
    //
    
    #include <stdio.h>
    #include <pthread.h>
    
    #define NUMBEROFTHREADS 4
    
    int IsPrime(long int num)
    {
      long int i1;
      long int i2;
      for(i1 = 2; i1 < num; i1++)
      {
        for(i2 = 2; i2 < num; i2++)
        {
          if(i1 * i2 == num) return 0;
        }
      }
      return 1;
    }
    
    void *DoWork(void *args)
    {
      long int count = 0;
      long int i;
      
      for(i = 2; i < 9223372036854775807; i++)
      {
        if(IsPrime(i))
        {
          count++;
        }
      }
      printf("Count is %ld\n", count);
      pthread_exit(NULL);
    }
    
    int main(int argc, const char * argv[])
    {
    
      pthread_t threads[NUMBEROFTHREADS];
      int i;
      for(i = 0; i < NUMBEROFTHREADS; i++)
      {
        pthread_create(&threads[i], NULL, DoWork, (void*)&i);
      }
      
      for(i = 0; i < NUMBEROFTHREADS; i++)
      {
        void *status;
        int rc = pthread_join(threads[i], &status);
      }
        
      return 0;
    }
    
    
     

Share This Page