• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Curious about latencies with bindings [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Curious about latencies with bindings [SOLVED]


  • Subject: Re: Curious about latencies with bindings [SOLVED]
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 5 Dec 2007 15:44:25 -0600


On Jan 23, 2006, at 6:28 PM, Ricky Sharp wrote:

I've added an automated test infrastructure to my app that is driven via a timer which fires every 100 ms. Each time it fires an "opcode" is executed which does things like simulate a click on a button or set some property of a custom control.

While everything works a-ok, I decided that since I was using a dual 2GHz G5, that I'd experiment by pushing the limits of that timer :)

Dropping the interval to 50 ms worked most of the time, but my script began to fail. Take this particular run (script steps re- written as English pseudocode:)

(1) enter in correct answer to math problem
(2) validate the "correct" progress bar was incremented by one.

What (1) does, among other things, is to increment the number of correct answers in my "Math Drill" model. Step (2) simply queries the custom control as to its value (the control is bound to my model). By having such a low interval, I'm seeing situations where the progress bar control has not yet been updated by the time the timer executes step (2).

So, out of curiosity, am I running into latency issues with bindings? Is there some way to sense that there are "pending updates"? I really don't need the timer to run this fast; again, this was just an experiment to see how far I could push things. But, if I could address these rare situations, my tests would all execute twice as fast :)


Responding to myself here for the sake of the archives.

After moving to an 8-core, my automated system would still fail in some situations. The culprit was not latency in bindings, but in how I was simulating keyboard events (e.g. to enter a string of Unicode characters).

What occurred was that for each separate character, I would post a keydown event. And, depending upon how many characters were being posted, it could be the case where the next time the timer fired, it fired before all keyboard events were processed.

All I needed to do was to make my key posting routine synchronous (basically polls/blocks until the event queue is void of keydowns). It is polling, but for each iteration, I call a blocking "nextEventInQueue" API that blocks for up to my timer's interval.

Now all is well; I can crank down my timer interval to as low as 40 ms. When I get faster machines in the future, that number can be further lowered.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Diagnosing NSString error in Leopard
  • Next by Date: Re: Diagnosing NSString error in Leopard
  • Previous by thread: Re: Diagnosing NSString error in Leopard
  • Next by thread: Canonical way of loading compound UI components from a NIB into some other UI?
  • Index(es):
    • Date
    • Thread