Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Cut down on the World Clock widget's CPU usage System 10.4
Tiger only hintI really like the World Clock (now that I have edited it to show the date, too), but I was asked to find a way to cut down on it's CPU usage. What I came up with was disabling the little red second hand.

First of all you'll need to open World Clock (Control-click on it in /Library/Widgets and choose Show Package Contents). Find WorldClock.js and open it with your favorite pure text editor. Find the following lines in the file:
context.rotate (secondsAngle);
context.translate (-3.5,-50.5);
context.drawImage (sechand, 0, 0, 7, 55);
and comment them out by puttting // at the start of each line, or /* before the first and */ after the last). That takes care of drawing the hand. Now change this line to stop it from calculating the sway of the second hand.

    timerInterval = setInterval("updateTime(true);", 1000);
to

    timerInterval = setInterval("updateTime(false);", 1000);
You could also change that 1000 to something higher. It sets the number of milliseconds between each time it recalculates the time and the angles that each hand is drawn at. A higher number will mean it changes the time less often (saving CPU). When done, save the changes, quit the editor, and then close (if it was open) and re-open the widget.
    •    
  • Currently 1.00 / 5
  You rated: 1 / 5 (2 votes cast)
 
[15,885 views]  

10.4: Cut down on the World Clock widget's CPU usage | 20 comments | Create New Account
Click here to return to the '10.4: Cut down on the World Clock widget's CPU usage' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Cut down on the World Clock widget's CPU usage
Authored by: shiyinjia on Jun 13, '05 10:58:32AM

Thanks for your hints about the world clock widget! I also followed your hint about adding additional cities. You mentioned that you edited it to show the date, could you post this info too?

Thanks

---
jeff hargrove
photography
www.jeffhargrove.net



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: barrysharp on Jun 13, '05 01:00:05PM

Geeesh - I don't mean to be overly critical about this, but I have three world clocks running all the time with their second hands operative. They take precious little cpu time and with the amount of white space on my 2x 2.5 GHz system it's of no significant consequence. Maybe this is more of a problem with systems with limited CPU resource but it sure isn't with the latest crop of Apple Macs IMO.

This CPU use needs quantifying with and without the second hand operative to allow others to make an informed decision.

---
Regards... Barry Sharp



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: diamondsw on Jun 13, '05 01:59:20PM
Yes, I imagine it isn't a problem with the second fastest Mac made. I hate to tell you, the VAST majority of people are still on G4's (and even G3's!), not a dual processor 2.5Ghz G5...

[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: barrysharp on Jun 14, '05 12:29:42AM

Oh pls - don't get so defensive. I was being constructive for heavens sake. I still maintain this needs qunatifying before people make the leap of faith. It's kinda like everybody rushing out to configure swap space on a separate partition or separate disk - what a waste of time.

---
Regards... Barry Sharp



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: sigma8 on Jun 14, '05 04:57:54PM

My mac is a laptop, and one thing I hate, is when the CPU is ramped up for no good reason, and my noisy fan spins up. I don't use the world clock widget very often, so I probably won't make this change.

But the second hand is pretty useless, and I think it's definitely a good tip for anyone who is making extensive use of the widgets, or who use their widget-top as an idle screen or screensaver.



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: barrysharp on Jun 14, '05 12:36:57AM

Oh - and in case you hadn't realized the World clock widget will only comsume CPU time when it's displaying and not while it's Docked. So if one only infrequently unDocks the Dashboard there's little reason to remove the second hand.

---
Regards... Barry Sharp



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: pete.boardman on Jun 13, '05 03:10:16PM

I also wanted to reduce cpu usage of this clock, since I'm running two or three of them on the desktop rather than in Dashboard. But I found I didn't need to switch off seconds altogether - I just removed the 'sproing' animation effect - which is cool and neat, but unnecessary. Before edits, the World Clock used 10% CPU; with edits, but still with seconds and a digital clock, I've got it down to 1.8%.

(

But the main modification I made was to convert to 24 hour analog operation. More here. :-)

The only problem is wondering what changes Apple make to the original when they issue a new version...



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: locklin on Jun 13, '05 09:22:05PM

Hey Pete,

How do you remove just the 'sproing' efect?



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: CraigStanton on Jun 14, '05 06:32:20AM

From my original hint:

Now change this line to stop it from calculating the sway of the second hand.
<code> timerInterval = setInterval("updateTime(true);", 1000);</code>
to
<code> timerInterval = setInterval("updateTime(false);", 1000);</code>



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: Jeff Fork on Mar 13, '08 03:31:12PM

obviously, yes, i know the post i am replying to is almost 2 years old, but i had the same question, so this might help someone.

also, the "no seconds" fix does not work in 10.5 as the "true" string does not exist.

to remove the "sproing" animation only, i found this:
find "sproing" in the WorldClock.js
find the line:

var secondsSweepbackMax = 0.15;

change to:

var secondsSweepbackMax = 0;

worked for me, hope this helps!



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: boredzo on Jun 13, '05 01:26:02PM

if you edit the World Clock widget while it's open, you don't have to close it; simply press ⌘R while your mouse cursor is over the open widget.



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: PCheese on Jun 13, '05 09:49:19PM
You have to click on the widget before pressing ?R.

I just changed the line that reads:
timerInterval = setInterval("updateTime(true);", 1000);
to
timerInterval = setInterval("updateTime(false);", 1000);
and processor usage dropped to 2% from 14%. That's the step for disabling the sweepback/sproing effect as mentioned above.

[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: PCheese on Jun 13, '05 09:52:15PM
Seems there's a bug in geeklog where if you enter an HTML entity such as &#x2318; it won't be escaped correctly after you preview your comment, so when submitting it'll get screwed up.

That ?R up there is supposed to be a ⌘R.

[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: locklin on Jun 13, '05 10:26:55PM

Cool, Thanks for the tip!



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: sblasl on Jun 14, '05 01:37:31AM

I would be interested in adding the date to the World Clock widget as well.

Thanks



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: barrysharp on Jun 14, '05 06:47:12PM

I decided to quantify the CPU time savings with and without the second hand display and came up with a 3.7% savings. I did this by determining the cpu time consumed by the *default* World Clock widget with a second hand active over a 60 second wall time and then again without the second hand being displayed. This number may not be absolute but I believe it does come close to quantifying the difference. I performed this on a 2x 2.5GHz PM running Tiger 10.4.1 with normal background system activities.

What would be nice I think would be for an option to display or not to display the second hand. For example, for local time I want the second hand display but for say London UK time I can live without the second hand. Someone should send this in as feedback to Apple. The 3.7% can add up if one has several World Clocks running - I have 5 World Clocks running.

---
Regards... Barry Sharp



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: CraigStanton on Jun 14, '05 09:53:52PM

Was that 3.7% less total CPU load, or was the Clock Widget CPU usage dropped by 3.7%?



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: barrysharp on Jun 14, '05 10:23:43PM

Hmmmm - you made me re-examine my arithmetic.\

With second hand active the World Clock consumed 2.53 secs cputime during a 60 sec wall time. Without second hand active it consumed 0.33 secs in the 60 sec wall time. So the second hand being active means cputime consumed is approx 7.7x that without second hand. Hope that makes sense. :-))

---
Regards... Barry Sharp



[ Reply to This | # ]
10.4: Cut down on the World Clock widget's CPU usage
Authored by: msalsbury on Sep 19, '05 11:53:05PM
Actually, the performance situation with the World Clock Widget is a LOT worse than people suspect. I recently began testing the Widget's performance on 10.4.2 by leaving the Dashboard open as much as I can on a spare Mac and taking snapshots of process activity every hour. What I've found is that the other default Widgets (Address Book, Calendar, Weather, and Calculator) take little to no CPU or RAM unless they're actually doing something - and even then they take very little. World Clock, on the other hand, grows steadily as it remains active. After leaving a system up for a week or two, I was shocked to find that World Clock was consuming over 46% of the CPU and over 150MB of RAM. I'm currently monitoring it over a longer period of time to get a better picture of the problem. If you're curious as to the current status, it can be found on my web site at:

http://mikesalsbury.com/mambo/content/view/238/1/ or by going to my home page and searching for "Dashboard".



[ Reply to This | # ]

10.4: Cut down on the World Clock widget's CPU usage
Authored by: heyotwell on Oct 03, '05 04:23:56PM

After reading this, I started monitoring my four running World Clocks, which are unmodified 10.4.2 versions. No matter how long they're left running, they never consume CPU time when the Dashboard's closed, though they do consume some memory. I don't reboot unless required by software updates, which is rare. In other words, I don't see the symptoms you describe at all.



[ Reply to This | # ]