[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Re: Strange performance in blit



Whoops. Forgive my haste and loss of focus right before sending that. There is a mistake.

Change line 89:
costs = []
to
costs_per_screen = []

Gumm

On 4/26/2014 18:01, bw wrote:
Howdy, folks,

I am getting some strange behavior in Surface.blit(). This is a mystery.

I blit a collection of images to to fill the screen. If I pan left or right even one pixel, blit consumes nearly 4x the CPU. It is only left or right: if I pan up or down performance is not impacted.

I've attached a program that attempts to demonstrate this. Hopefully you'll find it minimal and easy to comprehend. Please let me know:

- Am I doing something wrong, and how?
- Is this a legitimate issue, and how might I work around it?


Please read the program description for the steps to reproduce the issue:

"""strange.py - demonstrating strange performane in Surface.blit

This program fills a screen with sprites to produce a checkerboard background,
and demonstrates a problem.

Controls:

    UP,DOWN,LEFT,RIGHT  pan the background
    SPACE               center the background
    ESCAPE              quit

Reproducing the problem:

The times indicated in these steps are on a Intel i3 running Windows 7 64-bit. Times will vary on other machines. The time cost measured is in blit ONLY.

1. Observe the cost per blit in the window's caption. On my machine it costs
   about 0.0000015 seconds per blit.
2. Pan LEFT one or more pixels. Note the cost goes up nearly 4x (0.0000056). 3. Press SPACE to center the background. Note the cost goes back down to the
   original value.
4. Pan RIGHT just one or more pixels. Note the costs goes up as in step 2.
5. Press SPACE to center the background.
6. Pan UP or DOWN: the cost is not impacted.
"""

Gumm