Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 846165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:34:15+00:00 2026-05-15T06:34:15+00:00

Shark complains about a big performance hit with this line, which takes like 80%

  • 0

Shark complains about a big performance hit with this line, which takes like 80% of CPU time. I have a counter that is updated very frequently and performance seriously sucks.

It’s an custom UILabel subclass with -drawRect: implemented. Every time the counter value changes, this is used to draw the new text:

[self.text drawInRect:textRect withFont:correctedFont lineBreakMode:self.lineBreakMode alignment:self.textAlignment];

When I comment this line out, performance rocks. Its smooth and fast. So Shark isn’t wrong about this. But what could I do to improve this? Maybe go a level deeper? Does that make any sense?

Probably drawing text is really so incredible heavy…?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:34:15+00:00Added an answer on May 15, 2026 at 6:34 am

    There’s no reason the drawing of a single label should cause such a massive performance hit. If you’re updating it more than 30-60 times per second, though, the system may have trouble keeping up. In that case, you could use an NSTimer to only perform the drawing at fixed intervals. There’s no doubt that drawing text is expensive, but you’ve pretty much found the optimal way of doing the drawing itself, unless the label is only a single line, in which case you can use the slightly cheaper drawAtPoint:withAttributes:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Shark shows me that this method takes a HUGE performance hit. Like 80% in
I have the following case: All boats have a boat type like shark ,
I am posting something that looks like this: FavoritePerson: Dennis FavoriteAnimals: [{Type=Bear, Name=Bruno}, {Type=Shark,
I have a global that I would like to share across multiple files. Lets
I have developed a Web application (HTML5/browser based) for a client which requires fairly
I recently moved my Eclipse workspace directory and now Subclipse complains every time I
I have this app, originally written for iOS 2.x. I recently needed to add
My following script is producing an error (it complains about expecting 'then' keyword before
Greetings, I'm no XSL/XSLT/XML shark, I have worked with some, though, but I've never
Have a look at this F#/OCaml code: type AllPossible = | A of int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.