X CPU Time

simple program with SDL that makes a screen and then flips it 10,000
times. I then wrote a simple X program and using xshm display 10,000
times. When I am using the SDL program, top says that X is using a
good %20 or the cpu, while in the other one using xshm it uses about 1.5
or less. Can anyone explain this, as to why it is happening?

-Benjamin Meyer

simple program with SDL that makes a screen and then flips it 10,000
times. I then wrote a simple X program and using xshm display 10,000
times. When I am using the SDL program, top says that X is using a
good %20 or the cpu, while in the other one using xshm it uses about 1.5
or less. Can anyone explain this, as to why it is happening?

Are you calling XSync() after each flip in your xshm program?
If not the server may be batching them, and performing a single flip for
each X number of calls.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Sam Lantinga wrote:

simple program with SDL that makes a screen and then flips it 10,000
times. I then wrote a simple X program and using xshm display 10,000
times. When I am using the SDL program, top says that X is using a
good %20 or the cpu, while in the other one using xshm it uses about 1.5
or less. Can anyone explain this, as to why it is happening?

Are you calling XSync() after each flip in your xshm program?
If not the server may be batching them, and performing a single flip for
each X number of calls.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

I call XFlush()

-Benjamin Meyer

simple program with SDL that makes a screen and then flips it 10,000
times. I then wrote a simple X program and using xshm display 10,000
times. When I am using the SDL program, top says that X is using a
good %20 or the cpu, while in the other one using xshm it uses about 1.5
or less. Can anyone explain this, as to why it is happening?

Top isn’t really reliable. Also remember that you have at least 4 processes
running (your prog, X, top, and the top xterm), potentially competing for cpu.
The running times are what counts.

Sam Lantinga wrote:

simple program with SDL that makes a screen and then flips it 10,000
times. I then wrote a simple X program and using xshm display 10,000
times. When I am using the SDL program, top says that X is using a
good %20 or the cpu, while in the other one using xshm it uses about 1.5
or less. Can anyone explain this, as to why it is happening?

Are you calling XSync() after each flip in your xshm program?
If not the server may be batching them, and performing a single flip for
each X number of calls.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

I call XFlush()

Remember, you can’t write to the shared memory until the shm update has
actually completed, so you need to wait until you get a shm completion
event or call XSync() for valid numbers. Otherwise the X server may
discard overlapping copy calls when a copy is in progress.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software