static void lpass_log(enum log_level level, char *fmt, ...) { struct timeval tv; struct timezone tz; va_list ap; int req_level = lpass_log_level(); if (req_level < level) return; gettimeofday(&tv, &tz); printf("<%d> [" TIME_FMT "] ", level, TIME_ARGS(&tv)); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); }
static void print_performance_data (void) { GList *iter; gint i = 0; GstClockTime last_start = 0; CaptureTimingStats max; CaptureTimingStats min; CaptureTimingStats avg; CaptureTimingStats avg_wo_first; GstClockTime shot_to_shot; if (!performance_measure) return; parse_target_values (); /* Initialize stats */ min.shot_to_shot = -1; min.shot_to_save = -1; min.shot_to_snapshot = -1; min.preview_to_precapture = -1; min.shot_to_buffer = -1; memset (&avg, 0, sizeof (CaptureTimingStats)); memset (&avg_wo_first, 0, sizeof (CaptureTimingStats)); memset (&max, 0, sizeof (CaptureTimingStats)); g_print ("-- Performance results --\n"); g_print ("Startup time: %" TIME_FORMAT "; Target: %" TIME_FORMAT "\n", TIME_ARGS (startup_time - initial_time), TIME_ARGS (target_startup)); g_print ("Change mode time: %" TIME_FORMAT "; Target: %" TIME_FORMAT "\n", TIME_ARGS (change_mode_after - change_mode_before), TIME_ARGS (target_change_mode)); g_print ("\n | Shot to save |Shot to snapshot| Shot to shot |" "Preview to precap| Shot to buffer\n"); capture_times = g_list_reverse (capture_times); for (iter = capture_times; iter; iter = g_list_next (iter)) { CaptureTiming *t = (CaptureTiming *) iter->data; CaptureTimingStats stats; stats.shot_to_save = SHOT_TO_SAVE (t); stats.shot_to_snapshot = SHOT_TO_SNAPSHOT (t); stats.shot_to_shot = i == 0 ? 0 : t->start_capture - last_start; stats.preview_to_precapture = PREVIEW_TO_PRECAPTURE (t); stats.shot_to_buffer = SHOT_TO_BUFFER (t); PRINT_STATS (i, &stats); if (i != 0) { capture_timing_stats_add (&avg_wo_first, &stats); } capture_timing_stats_add (&avg, &stats); if (stats.shot_to_save < min.shot_to_save) { min.shot_to_save = stats.shot_to_save; } if (stats.shot_to_snapshot < min.shot_to_snapshot) { min.shot_to_snapshot = stats.shot_to_snapshot; } if (stats.shot_to_shot < min.shot_to_shot && stats.shot_to_shot > 0) { min.shot_to_shot = stats.shot_to_shot; } if (stats.preview_to_precapture < min.preview_to_precapture) { min.preview_to_precapture = stats.preview_to_precapture; } if (stats.shot_to_buffer < min.shot_to_buffer) { min.shot_to_buffer = stats.shot_to_buffer; } if (stats.shot_to_save > max.shot_to_save) { max.shot_to_save = stats.shot_to_save; } if (stats.shot_to_snapshot > max.shot_to_snapshot) { max.shot_to_snapshot = stats.shot_to_snapshot; } if (stats.shot_to_shot > max.shot_to_shot) { max.shot_to_shot = stats.shot_to_shot; } if (stats.preview_to_precapture > max.preview_to_precapture) { max.preview_to_precapture = stats.preview_to_precapture; } if (stats.shot_to_buffer > max.shot_to_buffer) { max.shot_to_buffer = stats.shot_to_buffer; } last_start = t->start_capture; i++; } if (i > 1) shot_to_shot = avg.shot_to_shot / (i - 1); else shot_to_shot = GST_CLOCK_TIME_NONE; capture_timing_stats_div (&avg, i); avg.shot_to_shot = shot_to_shot; if (i > 1) capture_timing_stats_div (&avg_wo_first, i - 1); else { memset (&avg_wo_first, 0, sizeof (CaptureTimingStats)); } g_print ("\n Stats | MIN | MAX |" " AVG | AVG wo First | Target | Diff \n"); g_print ("Shot to shot | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.shot_to_shot), TIME_ARGS (max.shot_to_shot), TIME_ARGS (avg.shot_to_shot), TIME_ARGS (avg_wo_first.shot_to_shot), TIME_ARGS (target_shot_to_shot), TIMEDIFF_ARGS (TIME_DIFF (avg.shot_to_shot, target_shot_to_shot))); g_print ("Shot to save | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.shot_to_save), TIME_ARGS (max.shot_to_save), TIME_ARGS (avg.shot_to_save), TIME_ARGS (avg_wo_first.shot_to_save), TIME_ARGS (target_shot_to_save), TIMEDIFF_ARGS (TIME_DIFF (avg.shot_to_save, target_shot_to_save))); g_print ("Shot to snapshot | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.shot_to_snapshot), TIME_ARGS (max.shot_to_snapshot), TIME_ARGS (avg.shot_to_snapshot), TIME_ARGS (avg_wo_first.shot_to_snapshot), TIME_ARGS (target_shot_to_snapshot), TIMEDIFF_ARGS (TIME_DIFF (avg.shot_to_snapshot, target_shot_to_snapshot))); g_print ("Preview to precapture | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.preview_to_precapture), TIME_ARGS (max.preview_to_precapture), TIME_ARGS (avg.preview_to_precapture), TIME_ARGS (avg_wo_first.preview_to_precapture), TIME_ARGS (target_preview_to_precapture), TIMEDIFF_ARGS (TIME_DIFF (avg.preview_to_precapture, target_preview_to_precapture))); g_print ("Shot to buffer | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.shot_to_buffer), TIME_ARGS (max.shot_to_buffer), TIME_ARGS (avg.shot_to_buffer), TIME_ARGS (avg_wo_first.shot_to_buffer), TIME_ARGS (target_shot_to_buffer), TIMEDIFF_ARGS (TIME_DIFF (avg.shot_to_buffer, target_shot_to_buffer))); }