+ snprintf(line, line_len, "rmdir %s", movie_dir);
+ system(line);
+}
+
+static void plot_io_movie(struct plot *plot)
+{
+ struct trace_file *tf;
+ char *movie_dir = create_movie_temp_dir();
+ int i, pid;
+ struct plot_history *history;
+ int batch_i;
+ int movie_len = 30;
+ int movie_frames_per_sec = 20;
+ int total_frames = movie_len * movie_frames_per_sec;
+ int rows, cols;
+ int batch_count;
+ int graph_width_factor = 5;
+ int orig_y_offset;
+
+ get_graph_size(&cols, &rows);
+ batch_count = cols / total_frames;
+
+ if (batch_count == 0)
+ batch_count = 1;
+
+ list_for_each_entry(tf, &all_traces, list) {
+ char label[256];
+ char *pos;
+
+ if (!tf->label)
+ label[0] = 0;
+ else {
+ strcpy(label, tf->label);
+ if (io_per_process)
+ strcat(label, " ");
+ }
+ pos = label + strlen(label);
+
+ i = 0;
+ while (i < cols) {
+ snprintf(line, line_len, "%s/%010d-%s.svg", movie_dir, i, output_filename);
+ set_plot_output(plot, line);
+ set_plot_title(plot, graph_title);
+ orig_y_offset = plot->start_y_offset;
+
+ plot->no_legend = 1;
+
+ set_graph_size(cols / graph_width_factor, rows / 8);
+ plot->timeline = i / graph_width_factor;
+
+ plot_tput(plot, tf->min_seconds, tf->max_seconds, 0);
+
+ plot_cpu(plot, tf->max_seconds,
+ "CPU System Time", CPU_SYS_GRAPH_INDEX, MPSTAT_SYS);
+
+ plot->direction = PLOT_ACROSS;
+ plot_queue_depth(plot, tf->min_seconds, tf->max_seconds);
+
+ /* movie graph starts here */
+ plot->start_y_offset = orig_y_offset;
+ set_graph_size(cols - cols / graph_width_factor, rows);
+ plot->no_legend = 0;
+ plot->timeline = 0;
+ plot->direction = PLOT_DOWN;;
+
+ if (movie_style == MOVIE_SPINDLE)
+ setup_axis_spindle(plot);
+ else
+ setup_axis(plot);
+
+ svg_alloc_legend(plot, count_io_plot_types() * 2);
+
+ history = alloc_plot_history(tf);
+ history->col = i;
+
+ for (pid = 0; pid < tf->io_plots; pid++) {
+ if (tf->gdd_reads[pid]) {
+ if (io_per_process)
+ strcpy(pos, tf->gdd_reads[pid]->label);
+ svg_add_legend(plot, label, " Reads", tf->gdd_reads[pid]->color);
+ }
+ if (tf->gdd_writes[pid]) {
+ if (io_per_process)
+ strcpy(pos, tf->gdd_writes[pid]->label);
+ svg_add_legend(plot, label, " Writes", tf->gdd_writes[pid]->color);
+ }
+ }
+
+ batch_i = 0;
+ while (i < cols && batch_i < batch_count) {
+ for (pid = 0; pid < tf->io_plots; pid++) {
+ if (tf->gdd_reads[pid]) {
+ svg_io_graph_movie(tf->gdd_reads[pid],
+ history->read_pid_history[pid],
+ i);
+ }
+ if (tf->gdd_writes[pid]) {
+ svg_io_graph_movie(tf->gdd_writes[pid],
+ history->write_pid_history[pid],
+ i);
+ }
+ }
+ i++;
+ batch_i++;
+ }
+
+ add_history(history, &movie_history);
+
+ plot_movie_history(plot, &movie_history);
+
+ svg_write_legend(plot);
+ close_plot(plot);
+ close_plot(plot);
+
+ close_plot_file(plot);
+ }
+ free_all_plot_history(&movie_history);
+ }
+ convert_movie_files(movie_dir);
+ encode_movie(movie_dir);
+ cleanup_movie(movie_dir);
+ free(movie_dir);
+}
+
+static void plot_latency(struct plot *plot, unsigned int min_seconds,
+ unsigned int max_seconds)
+{
+ struct trace_file *tf;
+ char *units;
+ char line[128];
+ u64 max = 0;
+
+ if (active_graphs[LATENCY_GRAPH_INDEX] == 0)
+ return;