Permalink
Browse files

fbtft: fix performance debug output

Now the fps number will show the actual framerate, and not the theoretical
framerate that could be achieved running continuous updates.
Throughput is also calculated.

Example:
 fb_ili9320 spi0.0: Display update: 3410 kB/s (43.977 ms), fps=16 (59.989 ms)
  • Loading branch information...
1 parent c48637f commit e207c4ec58429d24e8a03de5dce800c1a03dd36e @notro committed Sep 18, 2013
Showing with 27 additions and 10 deletions.
  1. +25 −10 fbtft-core.c
  2. +2 −0 fbtft.h
View
@@ -322,8 +322,9 @@ void fbtft_reset(struct fbtft_par *par)
void fbtft_update_display(struct fbtft_par *par, unsigned start_line, unsigned end_line)
{
size_t offset, len;
- struct timespec ts_start, ts_end, test_of_time;
- long ms, us, ns;
+ struct timespec ts_start, ts_end, ts_fps, ts_duration;
+ long fps_ms, fps_us, duration_ms, duration_us;
+ long fps, throughput;
bool timeit = false;
int ret = 0;
@@ -368,15 +369,29 @@ void fbtft_update_display(struct fbtft_par *par, unsigned start_line, unsigned e
if (unlikely(timeit)) {
getnstimeofday(&ts_end);
- test_of_time = timespec_sub(ts_end, ts_start);
- us = (test_of_time.tv_nsec / 1000) % 1000;
- ms = (test_of_time.tv_sec * 1000) + ((test_of_time.tv_nsec / 1000000) % 1000);
- ns = test_of_time.tv_nsec % 1000;
+ if (par->update_time.tv_nsec == 0 && par->update_time.tv_sec == 0) {
+ par->update_time.tv_sec = ts_start.tv_sec;
+ par->update_time.tv_nsec = ts_start.tv_nsec;
+ }
+ ts_fps = timespec_sub(ts_start, par->update_time);
+ par->update_time.tv_sec = ts_start.tv_sec;
+ par->update_time.tv_nsec = ts_start.tv_nsec;
+ fps_ms = (ts_fps.tv_sec * 1000) + ((ts_fps.tv_nsec / 1000000) % 1000);
+ fps_us = (ts_fps.tv_nsec / 1000) % 1000;
+ fps = fps_ms * 1000 + fps_us;
+ fps = fps ? 1000000 / fps : 0;
+
+ ts_duration = timespec_sub(ts_end, ts_start);
+ duration_ms = (ts_duration.tv_sec * 1000) + ((ts_duration.tv_nsec / 1000000) % 1000);
+ duration_us = (ts_duration.tv_nsec / 1000) % 1000;
+ throughput = duration_ms * 1000 + duration_us;
+ throughput = throughput ? (len * 1000) / throughput : 0;
+ throughput = throughput * 1000 / 1024;
+
dev_info(par->info->device,
- "Elapsed time for display update: %4lu.%.3lu%.3lu ms (fps: %2lu, lines=%u)\n",
- ms, us, ns,
- test_of_time.tv_nsec ? 1000000000 / test_of_time.tv_nsec : 0,
- end_line - start_line + 1);
+ "Display update: %ld kB/s (%ld.%.3ld ms), fps=%ld (%ld.%.3ld ms)\n",
+ throughput, duration_ms, duration_us,
+ fps, fps_ms, fps_us);
par->first_update_done = true;
}
}
View
@@ -207,6 +207,7 @@ struct fbtft_platform_data {
* @debug: Pointer to debug value
* @current_debug:
* @first_update_done: Used to only time the first display update
+ * @update_time: Used to calculate 'fps' in debug output
* @bgr: BGR mode/\n
* @extra: Extra info needed by driver
*/
@@ -248,6 +249,7 @@ struct fbtft_par {
} gamma;
unsigned long debug;
bool first_update_done;
+ struct timespec update_time;
bool bgr;
void *extra;
};

0 comments on commit e207c4e

Please sign in to comment.