[PATCH 2/2] gears: show FPS count (as in glxgears from mesa/demos)

Pekka Paalanen ppaalanen at gmail.com
Wed Jul 25 08:00:00 PDT 2012


On Wed, 25 Jul 2012 15:19:23 +0200
Olivier Blin <olivier.blin at softathome.com> wrote:

> ---
>  clients/gears.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/clients/gears.c b/clients/gears.c
> index 70ec86c..19165e7 100644
> --- a/clients/gears.c
> +++ b/clients/gears.c
> @@ -59,6 +59,8 @@ struct gears {
>  
>  	GLint gear_list[3];
>  	int fullscreen;
> +	int frames;
> +	uint32_t last_fps;
>  };
>  
>  struct gear_template {
> @@ -203,10 +205,33 @@ make_gear(const struct gear_template *t)
>  }
>  
>  static void
> +update_fps(struct gears *gears, uint32_t time)
> +{
> +	long diff_ms;
> +
> +	gears->frames++;
> +
> +	diff_ms = time - gears->last_fps;
> +
> +	if (diff_ms > 5000) {
> +		float seconds = diff_ms / 1000.0;
> +		float fps = gears->frames / seconds;
> +
> +		printf("%d frames in %6.3f seconds = %6.3f FPS\n", gears->frames, seconds, fps);

Gears will now need the same disclaimer as glxgears has,
otherwise end users will start using this as a generic
Wayland performance benchmark. I can imagine some
headlines on Phoronix when they compare Wayland gears with
glxgears and draw wildly incorrect conclusions.

I hope you will add a message explaining what this "fps" number
really means and what it can be used for.


Thanks,
pq


More information about the wayland-devel mailing list