[cairo] Very large number of lines

Andrea Canciani ranma42 at gmail.com
Mon Aug 30 11:31:49 PDT 2010


On Mon, Aug 30, 2010 at 8:20 PM, necko necko <opustenom at hotmail.com> wrote:
> Thank you for your email. The code I provided is just a sample. I need to
> show
> connections between a number of coordinates; so, in the real scenario the
> output file
> should display various lines.

How many lines do you expect to pass through the visible area?
Maybe a preprocessing your data to discard the invisible lines would allow
you to get an usable pdf and/or improve the performance of rasterization.

>
> The stroke() invoked on every 1000000th line produces the pdf file
> (otherwise, only one
> stroke at the end will not produce the pdf file). I know this because the
> size of the output
> file is around 100MB (otherwise, around 400kb). Clearly, I have problems
> displaying this
> file.
>
> As the way to get around this problem was to output PNG file, with the same
> strategy of
> invoking stroke() on every 1000000th line. The code I sent (for PNG files)
> spends *very*
> long time on each stroke() invoked.
>
> Therefore, I wonder whether there is a way to get the png output with this
> large number of connections.
> I tried to use similar strategy as with pdf files, but it is very time
> consuming.
> Perhaps you could try to invoke the code;

I did try your code. I found that (on my laptop) stroking every ~128
lines is much faster
for the image backend.
Anyway you should *NOT* keep stroking the same line over itself, it is
not a good
benchmark (it can easily be ten times slower than what you would get
using the real
data).

Profiling your code (when running on actual data) might give you some
more insight
about the real hot spot.

Andrea


More information about the cairo mailing list