octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Speeding Up gnuplot Interface with Binary Data


From: Daniel J Sebald
Subject: Speeding Up gnuplot Interface with Binary Data
Date: Tue, 07 Oct 2008 01:56:41 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020

John,

Attached is a patch using gnuplot's binary data input feature rather than ASCII 
data fifteen characters wide.  It does appear to speed up drawing a fair 
amount.  Less data is transmitted through the pipe, gnuplot doesn't have to 
input data as formated, and as I see it there is no need for handling NaN in a 
special way (it is just another value in IEEE format).

Let me know what you think.

Dan
--- /usr/local/share/octave/3.0.0+/m/plot/__go_draw_axes__.m    2008-01-30 
21:13:52.000000000 -0600
+++ __go_draw_axes__.m  2008-10-07 01:43:06.786018012 -0500
@@ -1213,11 +1213,11 @@
          fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z);
        endif
       endif
-      fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
-              usingclause{1}, titlespec{1}, withclause{1});
+      fprintf (plot_stream, "%s \"-\" binary record=%d %s %s %s \\\n", 
plot_cmd,
+              columns(data{1}), usingclause{1}, titlespec{1}, withclause{1});
       for i = 2:data_idx
-       fprintf (plot_stream, ", \"-\" %s %s %s \\\n",
-                usingclause{i}, titlespec{i}, withclause{i});
+       fprintf (plot_stream, ", \"-\" binary record=%d %s %s %s \\\n",
+                columns(data{i}), usingclause{i}, titlespec{i}, withclause{i});
       endfor
       fputs (plot_stream, ";\n");
       for i = 1:data_idx
@@ -1440,44 +1440,23 @@
   endif
 
   if (nd == 2)
-    nan_elts = find (sum (isnan (data)));
-    fmt = strcat (repmat ("%.15g ", 1, rows (data)), "\n");
-    if (isempty (nan_elts))
-      fprintf (plot_stream, fmt, data);
-    else
-      n = columns (data);
-      have_nans = true;
-      num_nan_elts = numel (nan_elts);
-      k = 1;
-      for i = 1:n
-       if (have_nans && i == nan_elts(k))
-         fputs (plot_stream, "\n");
-         have_nans = ++k <= num_nan_elts;
-       else
-         fprintf (plot_stream, fmt, data(:,i));
-       endif
-      endfor
-    endif
+      fwrite (plot_stream, data, "float32");
   elseif (nd == 3)
-    ## FIXME -- handle NaNs here too?
     if (parametric)
-      fprintf (plot_stream, "%.15g %.15g %.15g\n", data);
+      fwrite (plot_stream, data, "float32");
     else
       nr = rows (data);
       if (cdata)
        for j = 1:4:nr
-         fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data(j:j+3,:));
-         fputs (plot_stream, "\n");
+         fwrite (plot_stream, data(j:j+3,:), "float32");
        endfor
       else
        for j = 1:3:nr
-         fprintf (plot_stream, "%.15g %.15g %.15g\n", data(j:j+2,:));
-         fputs (plot_stream, "\n");
+         fwrite (plot_stream, data(j:j+2,:), "float32");
        endfor
       endif
     endif
   endif
-  fputs (plot_stream, "e\n");
 
 endfunction
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]