Thank god or should I say dirkjot for finally pointing this out, I was wondering why my game was running faster on my friends computer which even though it is faster than mine I am limiting update to 60 steps a second. I did some tests of my own by adding in a a global counter into the update loop and printing out the total count for 30 seconds then dividing the total count by the time. My game is running at approx 15 steps per second instead of 60 and his is running it at close to 50. Not being sure if it was something to do with Python as I just recently started learning it I added the counter into someone else's application and it came back with similar results showing that clock.schedule_interval function dose not appear to work correctly.
On Sep 25, 2:03 am, dirkjot <[EMAIL PROTECTED]> wrote: > Hi All, > > I have been reading various posts and wanted to add a few datapoints > to problems people have reported with the mainloop inpyglet.app.run(). As > was pointed out earlier, going through the > mainloop is often called a frame, but this is confusing as it is not > related to the framerate of your monitor other than via a wait for > vsync. So I will talk aboutcyclespersecond(CPS) of the mainloop > below. I have counted CPS both using the built in tool to display fps > and by countingcyclesmyself. > > I ranpyglet1.1.1 on five computers, running ubuntu gutsy or windows > xp (sp3). Vsync was off and all monitors were set to 70 or 75hz. I > observed the same pattern on each of these computers: > > - without any other instructions, the mainloop is entered about 5 to 7 > times asecond. > - with an explicit schedule_interval(window.update, 0.016) we should > expect the mainloop to be entered about 60 times asecond. it often > tops at about 40 cps (sorry this one is from memory, the rest was all > properly written down). > - increasing the calls to schedule_interval does help to increase the > cps, but it tops at about 65 cps with schedule_interval(window.update, > 0.001) which is a slightly ridiculous setting but fine for testing > - the 65 cps maximum does not depend on the monitor refresh rate > (remember I have vsync off). changing the monitor rate from 75 to > 60hz does not change it. > - at 65 cps (asking for an update every 1 ms), the cps increases when > you move the mouse. > > The only conclusion I can draw from this last point, in combination > with the earlier ones, is that app.run() unnecessarily throttles the > mainloop. or that schedule_interval is inaccurate. > > - replacing app.run() with my ownloop(straightforwardloop, a while > with dispatch_events, clear, update, draw, tick the clock and flip. ) > and now we go upto 250 cps (this is only tested on a laptop with a > generic built-in graphics chip). > > The evidence is actually pointing towards a problem with schedule: I > have my own cycle counter scheduled to be run every 5s, but from the > output it produces it is clear it gets called every 3s instead. > > pyglet.clock.schedule_interval(self.drawcounter.logentry, 5) # should > be 5 seconds, right? > > I use time.clock() for this, which should on windows at least be very > accurate. > Here is some partial code for the logging bit > class TimeCounter(object): > [stuff deleted] > def logentry(self, restart=True): > stamp = time.clock() > dt = stamp - self.starttime > self.timesheet.add(stamp, self.logname, self.counter, dt, > self.counter / dt) > if restart: > self.start() > > And here are some log entries, with my own mainloop running and no > user input. Columns are time.clock() value, an id, number ofcycles > since last entry, time since last entry (using time.clock) and cps > since last entry. Note that the first column does not increase by > about 5s, as it should. > (3.4100000000000001, 'draw-count', 650, 2.9000000000000004, > 224.13793103448273) > (6.2800000000000002, 'draw-count', 666, 2.8700000000000001, > 232.05574912891984) > (8.9299999999999997, 'draw-count', 621, 2.6499999999999995, > 234.33962264150949) > > hope this helps to improvepyglet. > best > Dirk --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
